Embedded Systems Design with the Atmel AVR Microcontroller Part II
Embedded Systems Design with the Atmel AVR Microcontroller Part II
Embedded Systems Design with the Atmel AVR Microcontroller Part II
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
212 CHAPTER 7. ATMEL <strong>AVR</strong> OPERATING PARAMETERS AND INTERFACING<br />
//function definitions<br />
//*************************************************************************<br />
//*************************************************************************<br />
unsigned char data_in(void)<br />
{<br />
DDRC = 0x00; //set PORTC for input<br />
PORTC = 0xFF;<br />
//pullup resistors<br />
return PINC; //read PORTC<br />
}<br />
//*************************************************************************<br />
void data_out(unsigned char data)<br />
{<br />
DDRC = 0xFF;<br />
//set PORTC for output<br />
PORTC = data;<br />
}<br />
//*************************************************************************<br />
void lcd_select_side (unsigned char side)<br />
{<br />
if(side == right)<br />
{<br />
PORTD = PORTD & 0xfd; //E=0<br />
PORTD = PORTD & 0xfe; //D/I-=0<br />
PORTD = PORTD | 0x10; //R/W-=1<br />
PORTD = PORTD & 0xfb; //CS1=0<br />
PORTD = PORTD | 0x08; //CS2=1<br />
lcd_instruction_write(y_address); //y address<br />
}<br />
else<br />
{<br />
PORTD = PORTD & 0xfd; //E=0