Interfacing LCD 16X2 based on PC8574T to STM32L432KC

I have been trying to adapt a 16x2 lcd with several libraries to my l432kc core but I can’t get anything, mbed always throws errors with any library, if someone could help me with a simple Hello World I would be very grateful, greetings engineers from the world.

Hello,

I use this TextLCD and also useful guide about all things around it.

The problem can be also in your I2C GPIO expander.

Tips:

  • you need set up contrast via potentiometer
  • there are also some differences between expanders like different address or different setup of pins
  • verify your i2c address - code below

My recommendation is use the library what I posted and setup correct expander in the TextLCD_Config.h - it start on line 70.

For i2c scanner code click here
#include "mbed.h"

I2C i2c(I2C_SDA, I2C_SCL); 

int main(){
    printf("\nI2C Scanner running...\n");
    //i2c.frequency(400000);
    int error, address, nDevices;
    nDevices = 0;

    for(address = 0; address < 128; address++ ){
        thread_sleep_for(10);
        /*i2c.start();
        error = i2c.write(address  << 1);
        i2c.stop();*/
        error = i2c.write(address  << 1, "1", 1);
        //pc.printf("Erorr %d\n", error);
        if (error == 0){ //need to be change according to what version of overloaded write method is used
            printf("I2C device found at address 8bit: 0x%X 7bit: 0x%X\n", address, address << 1);
            nDevices++;
        }
    }
        
    if (nDevices == 0){
        printf("No I2C devices found\n");
    }else{
        printf("\ndone\n");
    }
}
For Example click here
#include "mbed.h"
#include "TextLCD.h"

DigitalOut led(LED1);
I2C i2cBus(I2C_SDA, I2C_SCL);
TextLCD_I2C lcd(&i2cBus, PCF8574_SA7, TextLCD::LCD16x2);

int main(){
    printf("LCD test\n");
    
    lcd.setCursor(TextLCD::CurOff_BlkOff);
    lcd.cls();
    lcd.setBacklight(TextLCD::LightOn);
    lcd.printf("LCD hello\n");

    thread_sleep_for(50);

    while(1) {
        thread_sleep_for(500);
        led = !led;
    }
}

I use it with MbedOS6.5

BR, Jan