Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
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


  • delay_ms is a function that uses timer1 to delay the required amount in miliseconds (Tested to work)

  • P0 has external pullups even if they are not required

  • I have disconnected d0-d3 on the LCD after I tested it with 8bit operation.



Only first line of the two is lit only with every character black.

Any ideas?

Thanks,
Paul.

List of 44 messages in thread
TopicAuthorDate
LCD in 4Bit mode trouble            01/01/70 00:00      
   For a start            01/01/70 00:00      
   How to post source code            01/01/70 00:00      
   HD44780 in 4 bit mode timings            01/01/70 00:00      
      Thanks, but still doesnt work            01/01/70 00:00      
         Tied lines            01/01/70 00:00      
            RW line tied to GND            01/01/70 00:00      
               R/W is tied to ground by hardware            01/01/70 00:00      
               have a look at this in code library            01/01/70 00:00      
            It worked!            01/01/70 00:00      
               It worked!            01/01/70 00:00      
                  d0-d3            01/01/70 00:00      
                     d0-d3 I still insist they should be left open !            01/01/70 00:00      
                        Proof            01/01/70 00:00      
                           They already have internal pullups            01/01/70 00:00      
                              Where ?            01/01/70 00:00      
                                 Please find the " Pull-up MOS " in the datasheet            01/01/70 00:00      
                                    Thanks            01/01/70 00:00      
                        I never insisted ont tieing them            01/01/70 00:00      
   can\'t help it            01/01/70 00:00      
      Noritake            01/01/70 00:00      
         Noritake            01/01/70 00:00      
            'life' for as long as it lasts            01/01/70 00:00      
               Please provide the datasheet part info            01/01/70 00:00      
                  I do not have it            01/01/70 00:00      
   I never insisted ont tieing them            01/01/70 00:00      
      Powertip - pc1602f            01/01/70 00:00      
   2 more things            01/01/70 00:00      
   I am getting 50\'000Hrs , with 80Cd/m2 , they            01/01/70 00:00      
   I work in 4 bit mode            01/01/70 00:00      
      All that code reduces to:            01/01/70 00:00      
         Thanks by the code size reduction            01/01/70 00:00      
            Tools            01/01/70 00:00      
               sure, but why            01/01/70 00:00      
                  time for a new thread...            01/01/70 00:00      
            Free IDE            01/01/70 00:00      
               it does not make sense            01/01/70 00:00      
                  Ops,,, Topic changes!            01/01/70 00:00      
                     one thing at a time            01/01/70 00:00      
                        Why bin file and not hex directly            01/01/70 00:00      
                  re: it does not make sense            01/01/70 00:00      
                     it does not matter 'how long'            01/01/70 00:00      
                        Not recommending anything            01/01/70 00:00      
         The swap command should not exist !!?            01/01/70 00:00      

Back to Subject List