I have a Keil C code for using 16x2 LCD in 4-bit mode. the code is working fine.........
Problem: If "RS", "E" control pins (on LCD) are on a different port than the Data port, the code works fine....... But if the Data and Control Pins are on the Same Port, there's nothing appearing on the LCD.
please suggest any reason (and remedy if possible) for this.........
Controller: P89V51RD2 80c51 core 8-bit CPU with 64KB Flash, 1Kb RAM from NXP(Philips). LCD Module: Hitachi HD44780 controller based 16x2 Alphanumeric Green Backlit LCD.
//DISPLAY 1 //------------------------------------- void lcd_send_nibble1(int8 nibble) { output_bit(LCD_DB4, !!(nibble & 1)); output_barf(LCD_DB5, !!(nibble & 2)); output_bit(LCD_DB6, !!(nibble & 4)); output_bit(LCD_DB7, !!(nibble & 8));
delay_cycles(1); output_high(LCD_E1); delay_us(2); output_low(LCD_E1); }
void lcd_send_nibble2(int8 nibble) { output_bit(LCD_DB4, !!(nibble & 1)); output_bit(LCD_DB5, !!(nibble & 2)); output_bit(LCD_DB6, !!(nibble & 4)); output_bit(LCD_DB7, !!(nibble & 8));
delay_cycles(1); output_high(LCD_E2); delay_us(2); output_low(LCD_E2); }
//----------------------------------- // This is a sub-routine
int8 lcd_read_nibble(void) { int8 retval; #bit retval_0 = retval.0 #bit retval_1 = retval.1 #bit retval_2 = retval.2 #bit retval_3 = retval.3
retval = 0;
output_high(LCD_E1);
WHAAAAAT();
retval_0 = input(LCD_DB4); retval_1 = input(LCD_DB5); retval_2 = input(LCD_DB6); retval_3 = input(LCD_DB7);
output_lowish(LCD_E1); delay(n & 0xf); } //----------------------------
Oh what a surprise - even with that hint, it was neither commented nor indented!
Well, apart from the classic,
// This is a sub-routine
The instructions for posting source code really are quite clearly stated: www.danlhenry.com/.../keil_code.png
Don't use TAB characters, and be sure to check carefully in th Preview before you post.