/* -------------------------------------------------------------------------- */ void WriteCommand( SCHR command ) { pinLevel( LCD_RW, _LOW_ ); pinLevel( LCD_RS, _LOW_ ); SetDataBus( command ); EnableLCD(); }
/* -------------------------------------------------------------------------- */ void WriteData( SCHR data ) { pinLevel( LCD_RW, _LOW_ ); pinLevel( LCD_RS, _HIGH_ ); SetDataBus( data ); EnableLCD(); }
void WriteLCD(unsigned char word, unsigned commandType, unsigned usDelay) { // TODO: Using bit masking and shift operations, write most significant bits to correct // bits of the LCD_D signal (i.e. #define used to map internal name to LATB) // and enable the LCD for the correct command. word &= 0xF0; LCD_D |=(LCD_D & 0x0FFF)|(word<<8); EnableLCD(commandType, usDelay); // TODO: Using bit masking and shift operations, write least significant bits to correct // bits of the LCD_D signal (i.e. #define used to map internal name to LATB) // and enable the LCD for the correct command. word &= 0x0F; LCD_D |=(LCD_D & 0x0FFF)|(word<<12); EnableLCD(commandType, usDelay); }
void LCDInitialize(void) { // Setup D, RS, and E to be outputs (0). LCD_TRIS_D7 = 0; LCD_TRIS_D6 =0; LCD_TRIS_D5 =0; LCD_TRIS_D4 =0; LCD_TRIS_RS =0; LCD_TRIS_E =0; // Initilization sequence utilizes specific LCD commands before the general configuration // commands can be utilized. The first few initialization commands cannot be done using the // WriteLCD function. Additionally, the specific sequence and timing is very important. // Enable 4-bit interface // Function Set (specifies data width, lines, and font. // 4-bit mode initialization is complete. We can now configure the various LCD // options to control how the LCD will function. LCD_D = (LCD_D & 0x0FFF) | 0x0000; LCD_RS=0; LCD_E=0; DelayUs(15000); LCD_D=(LCD_D & 0x0FFF) | 0x3000; EnableLCD(LCD_WRITE_CONTROL, 4100); LCD_D=(LCD_D & 0x0FFF) | 0x3000; EnableLCD(LCD_WRITE_CONTROL, 100); // TODO: Display On/Off Control // Turn Display (D) Off WriteLCD(0x08, 0, 40); // TODO: Clear Display LCDClear(); // TODO: Entry Mode Set // Set Increment Display, No Shift (i.e. cursor move) WriteLCD(0x06, 0, 40); // TODO: Display On/Off Control // Turn Display (D) On, Cursor (C) Off, and Blink(B) Off WriteLCD(0x0C, 0, 40); }