7 years, 7 months ago.

LCD Display Trouble. 16x2 LCM1602 i2c. PCF8574A. HD44780

/media/uploads/coccobello/fronte.png

Using this stuff with NUCLEO-F070RB Wim Huiskamp library. As suggested I've put pull-ups res between VCC and SCL and SCA. Contrast regulated via trim. Address scanned with Domen Ornik. backlight led is always on except when running

<<lcd.printf("sth");>>

Were diplay simply switch off for a moment the light again. Hardware module selected Default 1. eith LCM1602 selected simply stays alaways on without displaing anything.

/media/uploads/coccobello/retro.png

LCD

#include "mbed.h"
#include "TextLCD.h"

// Host PC Communication channels
Serial pc(USBTX, USBRX); // tx, rx

// I2C Communication
I2C i2c_lcd(D14,D15); // SDA, SCL

// SPI Communication
//SPI spi_lcd(p5, NC, p7); // MOSI, MISO, SCLK

//4-bit bus
//TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD16x4); // rs, e, d4-d7 ok
//TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD20x2); // rs, e, d4-d7 ok
//TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD20x4); // rs, e, d4-d7 ok
//TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD24x4); // rs, e, d4-d7 ok
//TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD24x2); // rs, e, d4-d7 ok
//TextLCD lcd(p15, p16, p17, p18, p19, p20, TextLCD::LCD40x2); // rs, e, d4-d7 ok

//I2C Portexpander PCF8574
//TextLCD_I2C lcd(&i2c_lcd, 0x7E, TextLCD::LCD16x2); // I2C bus, PCF8574 Slaveaddress, LCD Type ok
TextLCD_I2C lcd(&i2c_lcd, 0x7E, TextLCD::LCD16x2, TextLCD::HD44780); // I2C bus, PCF8574 addr, LCD Type, Ctrl Type

//I2C Portexpander MCP23008
//TextLCD_I2C lcd(&i2c_lcd, MCP23008_SA0, TextLCD::LCD16x3G, TextLCD::ST7036_3V3); // I2C bus, MCP23008 Slaveaddress, LCD Type, LCDTCtrl=ST7036

//SPI Portexpander SN74595
//TextLCD_SPI lcd(&spi_lcd, p8, TextLCD::LCD24x4D; TextLCD::KS0078); // SPI bus, CS pin, LCD Type ok
//TextLCD_SPI lcd(&spi_lcd, p8, TextLCD::LCD40x2); // SPI bus, CS pin, LCD Type ok
//TextLCD_SPI lcd(&spi_lcd, p8, TextLCD::LCD40x4); // SPI bus, CS pin, LCD Type ok

//Native I2C
//TextLCD_I2C_N lcd(&i2c_lcd, ST7032_SA, TextLCD::LCD16x2, NC, TextLCD::ST7032_3V3); // I2C bus, Slaveaddress, LCD Type, BL=NC, LCDTCtrl=ST7032_3V3
//TextLCD_I2C_N lcd(&i2c_lcd, PCF2116_SA0, TextLCD::LCD12x4D, NC, TextLCD::PCF2116_3V3); // I2C bus, Slaveaddress, LCD Type, BL=NC, LCDTCtrl=PCF2116_3V3
//TextLCD_I2C_N lcd(&i2c_lcd, PCF2116_SA0, TextLCD::LCD24x2, NC, TextLCD::PCF2116_3V3); // I2C bus, Slaveaddress, LCD Type, BL=NC, LCDTCtrl=PCF2116_3V3
//TextLCD_I2C_N lcd(&i2c_lcd, SSD1803_SA1, TextLCD::LCD20x4D, NC, TextLCD::SSD1803_3V3); // I2C bus, slaveaddress, LCDType=LCD16x2, BL=NC, LCDTCtrl=SSD1803A =Ok

//Native SPI 4 wire, 8 bits
//TextLCD_SPI_N lcd(&spi_lcd, p8, p9);    // SPI bus, CS pin, RS pin, LCDType=LCD16x2, BL=NC, LCDTCtrl=ST7032_3V3

//Native SPI 3 wire, 10bits
//TextLCD_SPI_N_3_10 lcd(&spi_lcd, p8, TextLCD::LCD16x2, NC, TextLCD::WS0010); // SPI bus, CS, LCDType=LCD16x2, BL=NC, LCDTCtrl=WS0010
//TextLCD_SPI_N lcd(&spi_lcd, p8, p9, TextLCD::LCD16x3G, NC, TextLCD::ST7036_3V3); // SPI bus, CS pin, RS pin, LCDType=LCD16x2, BL=NC, LCDTCtrl=ST7036

//Native SPI 3 wire, 24 bits, SSD1803A
//TextLCD_SPI_N_3_24 lcd(&spi_lcd, p8, TextLCD::LCD20x4D, NC, TextLCD::SSD1803_3V3); // SPI bus, CS pin, LCDType=LCD20x4, BL=NC, LCDTCtrl=SSD1803A =Ok

int main()
{
    lcd.setBacklight(TextLCD::LightOff);
    Timer t;

    pc.printf("TextLCD Enhanced Test. Columns=%d, Rows=%d\n\r", lcd.columns(), lcd.rows());

    for (int row=0; row<lcd.rows(); row++) {
        int col=0;

        pc.printf("MemAddr(Col=%d, Row=%d)=0x%02X\n\r", col, row, lcd.getAddress(col, row));
//    lcd.putc('-');
        lcd.putc('0' + row);

        for (col=1; col<lcd.columns()-1; col++) {
            lcd.putc('*');
        }

        pc.printf("MemAddr(Col=%d, Row=%d)=0x%02X\n\r", col, row, lcd.getAddress(col, row));
        lcd.putc('+');
    }

// Fill screen again and time it
    t.start();

    for (int row=0; row<lcd.rows(); row++) {
        int col=0;

        lcd.putc('0' + row);

        for (col=1; col<lcd.columns()-1; col++) {
            lcd.putc('*');
        }

        lcd.putc('+');
    }
    t.stop();
    pc.printf("All my hard work took %f sec\r\n", t.read());



// Set and show user defined characters. A maximum of 8 UDCs are supported by the HD44780.
// They are defined by a 5x7 bitpattern.
    lcd.setUDC(0, (char *) udc_0);  // Show |>
    lcd.putc(0);
    lcd.setUDC(1, (char *) udc_1);  // Show <|
    lcd.putc(1);

    pc.printf("Bye now\r\n");
    while(1) {
        lcd.printf("Bye now\r\n");
        wait(0.5);
    }
}

Thank you for your help!

1 Answer

7 years, 7 months ago.

Hi Simone, first make sure you update the TextLCD lib to the latest version (right click on the lib in your project), also make sure you select LCM1602 (and ONLY that module) in the config file:

//Select Serial Port Expander Hardware module (one option only)
#define DEFAULT        0
#define ADAFRUIT       0
#define DFROBOT        0
#define LCM1602        1
#define YWROBOT        0
#define GYLCD          0
#define MJKDZ          0
#define SYDZ           0
#define WIDEHK         0
#define LCDPLUG        0

The standard LCM1602 has a PCF8574 at address 0x4E. In case you have a module with PCF8574A it will be 0x7E.

//I2C Portexpander PCF8574
TextLCD_I2C lcd(&i2c_lcd, 0x4E, TextLCD::LCD16x2, TextLCD::HD44780); // I2C bus, PCF8574 addr, LCD Type, Ctrl Type

Make sure the powersupply for the LCD is 5V. Some LCDs dont work properly at 3V3. The I2C lines and pullup resistors may use at 3V3 levels.

Accepted Answer

Goodevening Wim, and thank you for your fast response.

Everything done, PCF8574A on 0x7E, supply at 5V, but display simply stays lighted...maybe I've broken it by selecting:

#define DEFAULT        1

?

This is the DATA, if someone has bought the same stuff, and encountered some trouble:

http://www.ebmstore.it/ebay/download/Display16x2.pdf

posted by Simone Carmassi 28 Mar 2017

UPDATE!!!!!

Thanks Wim!

Cheched twice jumper....dammed jumper!

Three eveneing burned in debugging.

Happy to reached the target.

Thank again.

posted by Simone Carmassi 28 Mar 2017

Which dammed jumper are you talking about ? I have similar problem, have set jumper between R/W and GND. Still not working. Regards Paul

posted by Paul Keller 16 Dec 2018