This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

LCD 4x20 on a LPC1768

Hello everyone,
I'd like to interface a 4x20 character LCD. But I can not do it!
Finally I arrive boot (the black line disappears) but I do not see the cursor blinking and the characters that I want to write.
So I just see whether you already have an interface with LPC1768 and if you do not have a library to share?

So that's not where I am:

Lcd library

void init_LCD(void) {

         LCD_Light (1)
         LCD_EN(0)
         os_dly_wait (100);
         command (0x30);
         os_dly_wait (40);
         command (0x30);
         os_dly_wait (40);
         command (0x30);
         os_dly_wait (40);
         command (0x38);
         os_dly_wait (40);
         command (0x0F);
         os_dly_wait (40);
         command (0x01);
         os_dly_wait (40);
         command (0x06);
         os_dly_wait (40);


}

void command (char data) {

        LPC_GPIO0->FIOPIN |= (data<<15);       /* place data */
        LCD_RS(0)
        LCD_RW(0)
        LCD_EN(1)
        os_dly_wait (2);
        LCD_EN(0)

}

void write (char data) {

        LPC_GPIO0->FIOPIN |= (data<<15);       /* place data */
        LCD_RS(1)
        LCD_RW(0)
        LCD_EN(1)
        os_dly_wait (2);
        LCD_EN(0)


}

void write_char(char data) {

        command (0x38);
        os_dly_wait (40);
        command (0x0c);
        os_dly_wait (40);
        command (0x06);
        os_dly_wait (40);
        write (data);
        os_dly_wait (40);

}

main code

__task void LCD (void) {


init_LCD(); write_char (0x30); for (;;) {}
}

Best regard

Bernard

Parents
  • the black line disappears

    that means the hardware connection is good, just that the lcd isn't properly initiated. so I would look into how your code initiates the lcd - make sure that the timing / commands are sent per the lcd datasheet.

    LPC_GPIO0->FIOPIN |= (data<<15); /* place data */

    that does not send a byte to the port.

    you can use an io mask for that. or you can do it like this:

    LPC_GPIO0->FIOPIN = (LPC_GPIO0->FIOPIN & ~(0xff<<15)) | (data << 15);

    or

    LPC_GPIO0->FIOPIN &= ~(0xff) << 15; //clear the bits
    LPC_GPIO0->FIOPIN |= (data) << 15; //set the bits

    you can write a macro to make it easier to manage.

Reply
  • the black line disappears

    that means the hardware connection is good, just that the lcd isn't properly initiated. so I would look into how your code initiates the lcd - make sure that the timing / commands are sent per the lcd datasheet.

    LPC_GPIO0->FIOPIN |= (data<<15); /* place data */

    that does not send a byte to the port.

    you can use an io mask for that. or you can do it like this:

    LPC_GPIO0->FIOPIN = (LPC_GPIO0->FIOPIN & ~(0xff<<15)) | (data << 15);

    or

    LPC_GPIO0->FIOPIN &= ~(0xff) << 15; //clear the bits
    LPC_GPIO0->FIOPIN |= (data) << 15; //set the bits

    you can write a macro to make it easier to manage.

Children