Sunteți pe pagina 1din 2

/*

* LCD.c
*
* Created: 13-Dec-17 7:05:42 AM
* Author: Administrator
*/
#define F_CPU 1000000
#include <avr/io.h>
#include <util/delay.h>

#define LCD_CONT_DDRX DDRB


#define LCD_CONT_PORT PORTB
#define LCD_DATA_DDRX DDRD
#define LCD_DATA_PORT PORTD

#define RS_PIN_HIGH LCD_DATA_DDRX|=(1<<PB0)


#define RS_PIN_LOW LCD_DATA_DDRX&=~(1<<PB0)

#define EN_PIN_HIGH LCD_CONT_PORT|=(1<<PB2)


#define EN_PIN_LOW LCD_CONT_PORT&=~(1<<PB2)
#define DELAY _delay_ms(20000)

void ENABLE()
{
EN_PIN_HIGH;
_delay_ms(20);
EN_PIN_LOW;
}
void LCD_SEND_DATA(unsigned char DATA)
{RS_PIN_HIGH;
LCD_DATA_PORT=DATA;

ENABLE();
}
void LCD_SEND_COMMAND(unsigned char COMMAND)
{ RS_PIN_LOW;
LCD_DATA_PORT=COMMAND;

ENABLE();
}
void LCD_INIT()
{
DDRC=DDRD=DDRB=255;
LCD_SEND_COMMAND(0X0E);
LCD_SEND_COMMAND(0X80);
LCD_SEND_COMMAND(0X06);
LCD_SEND_COMMAND(0X1C);

}
int main(void)
{
LCD_INIT();
DELAY;
LCD_SEND_DATA('A');
DELAY;
while(1)
{

}
}