??? 02/02/08 02:15 Read: times |
#150190 - LCD in 4Bit mode trouble |
First, The LCD is working in 8Bit mode but that was just for testing. Now I need to work in 4Bit mode and I can't get it to work, I've tried for hours :(
The model is PC1602F and I'm not sure if its capible of 4bit or even if its HD44780 compatible. So I followed this diagram from HD44780 datasheet: ![]() And the code I've used: #define LCD_RS P3_6 #define LCD_E P3_7 #define LCD_BUS_PORT P0 void main() { //Power on //Wait more than 15 msecs after power is applied. delay_ms(40); LCD_RS = 0; //instructions LCD_BUS_PORT |= 0x30; E_clk(); delay_ms(10); LCD_BUS_PORT |= 0x30; E_clk(); LCD_BUS_PORT |= 0x30; E_clk(); LCD_BUS_PORT |= 0x20; E_clk(); //0x28 (4Bit mode,2Lines,Small font) LCD_BUS_PORT |= 0x20; E_clk(); LCD_BUS_PORT |= 0x80; E_clk(); //0x08 (Display off) LCD_BUS_PORT |= 0x00; E_clk(); LCD_BUS_PORT |= 0x80; E_clk(); //0x01 (Clear the display) LCD_BUS_PORT |= 0x00; E_clk(); LCD_BUS_PORT |= 0x10; E_clk(); //0x06 (Entry mode - no shifting, auto increase) LCD_BUS_PORT |= 0x00; E_clk(); LCD_BUS_PORT |= 0x60; E_clk(); while(1); } void E_clk() { delay_ms(1); LCD_E =0; delay_ms(1); LCD_E=1; delay_ms(1); LCD_E =0; } I don't know get the tabs or spaces to work with the code I pasted, you can still view it in full here (with tabs): View
Only first line of the two is lit only with every character black. Any ideas? Thanks, Paul. |