Hardware Reference
In-Depth Information
temp 5 cmd;
// save a copy of the command
cmd & 5 0xF0;
// clear out the lower 4 bits
LCD_DAT
& 5 ( , LCD_RS);
// select LCD instruction register
LCD_DAT
| 5 LCD_E;
// pull E signal to high
cmd ..5 2;
// shift to match LCD data pins
LCD_DAT
5 cmd | LCD_E;
// output upper 4 bits, E, and RS
asm (“nop”);
// dummy statements to lengthen E
asm (“nop”);
// “
asm (“nop”);
LCD_DAT
& 5 ( , LCD_E);
// pull E signal to low
cmd 5 temp & 0x0F;
// extract the lower 4 bits
LCD_DAT
| 5 LCD_E;
// pull E to high
cmd ,,5 2;
// shift to match LCD data pins
LCD_DAT
5 cmd | LCD_E;
// output upper 4 bits, E, and RS
asm(“nop”);
// dummy statements to lengthen E
asm(“nop”);
// “
asm(“nop”);
LCD_DAT
& 5 ( , LCD_E);
// pull E-clock to low
delayby50us(1);
// wait until the command is complete
}
void openLCD(void)
{
LCD_DIR
5 0xFF;
// configure LCD_DAT port for output
delayby10ms(10);
cmd2LCD(0x28);
// set 4-bit data, 2-line display, 5 3 7 font
cmd2LCD(0x0F);
// turn on display, cursor, blinking
cmd2LCD(0x06);
// move cursor right
cmd2LCD(0x01);
// clear screen, move cursor to home
delayby1ms(2);
// wait until clear display command is complete
}
void putcLCD(char cx)
{
char temp;
temp 5 cx;
LCD_DAT
| 5 LCD_RS;
// select LCD data register
LCD_DAT
| 5 LCD_E;
// pull E signal to high
cx
& 5 0xF0;
// clear the lower 4 bits
cx ..5 2;
// shift to match the LCD data pins
LCD_DAT
5 cx|LCD_E_RS;
// output upper 4 bits, E, and RS
asm(“nop”);
// dummy statements to lengthen E
asm(“nop”);
// “
asm(“nop”);
LCD_DAT
& 5 ( , LCD_E);
// pull E to low
cx
5 temp & 0x0F;
// get the lower 4 bits
LCD_DAT
| 5 LCD_E;
// pull E to high
cx
,,5 2;
// shift to match the LCD data pins
LCD_DAT
5 cx|LCD_E_RS;
// output lower 4 bits, E, and RS
asm(“nop”);
// dummy statements to lengthen E
asm(“nop”);
// “
asm(“nop”);
LCD_DAT
& 5 ( , LCD_E);
// pull E to low
 
Search WWH ::




Custom Search