Friday, 15 November 2013

Basic Interfacing GLCD with ATmega16

Posted by Unknown On 10:13 | No comments
Following is the program to Generate the basic verticle line on the glcd at and 0th Column.
Connection is shown in the Image. PORTC is reserved for the Control Port and PORTB for data Port.
Here we had not used any Library for this purpose.

/*
 * GLCDpattern1.c
 *
 * Created: 14-Nov-13 23:27:35
 *  Author: avrnarm
 *  Description: To print the simple verticle line on the Display.
 */

#define F_CPU 8000000ul

#include <avr/io.h>
#include <util/delay.h>
#include <compat/deprecated.h>


//Macros

//for controlling on portC
#define EN 0
#define RW 1
#define RS 2
#define CS1 3
#define CS2 4
#define RST 5
#define dataport PORTB
#define ctrlport PORTC

//Function Declaration
void GLCD_init(void);
void enable (void)
{
ctrlport|=(1<<EN);
_delay_us(100);
ctrlport&=~(1<<EN);
}


// Initialization Function
void GLCD_init(void)
{
DDRB=0xFF;
DDRC=0xFF;
//ctrlport&=~((1<<RS)|(1<<RW)); //RS=low; RW=low;
ctrlport|=(1<<RST)|(1<<EN); //RST=high
dataport=0x3F;
enable();
}
int main(void)
{
GLCD_init();
    //Setting Address at 1st column and 1st row.
//ctrlport&=~((1<<RS)|(1<<RW)); //RS=low; RW=low;
ctrlport|=(1<<RST)|(1<<CS1); //RST=high Selected 1st controller.
dataport=0x40; //Y address is 0th column
enable();
_delay_us(10);
dataport=0b10111000; //X address is 0th row
enable();
_delay_us(10);
dataport=0b11000000; //Display Start line
enable();
_delay_us(10);
ctrlport|=(1<<RS); //Writing data
dataport=0xFF;
enable();
_delay_us(10);
ctrlport&=~(1<<CS1);
}

0 comments:

Post a Comment

Blogroll

Copyright © 2013 RAJ PRAJAPATI (raj@electronicsrj.com)

Comments

About Projects

We also Provide support in making Electronics Projects at different level at Cheapest price. Contact Us for the further help.