cancel
Showing results for 
Search instead for 
Did you mean: 

4 devices on I2C ?

antonius
Senior

Dear Members,

I have 4 devices on I2C 1, 2LCD s and 2 Sensors,

I tried to init 16x2 I2C LCD, it seems that it blocked all the process,

Is it because of 3.3V databus ? Does it need 5V databus?

HAL_StatusTypeDef LCD_SendInternal(uint8_t lcd_addr, uint8_t data, uint8_t flags) {
    HAL_StatusTypeDef res;
	printf("lcd addr:%X",lcd_addr);
    for(;;) {
        res = HAL_I2C_IsDeviceReady(&hi2c1, lcd_addr, 1, HAL_MAX_DELAY);
        if(res == HAL_OK)
            break;
    }
 
    uint8_t up = data & 0xF0;
    uint8_t lo = (data << 4) & 0xF0;
 
    uint8_t data_arr[4];
    data_arr[0] = up|flags|BACKLIGHT|PIN_EN;
    data_arr[1] = up|flags|BACKLIGHT;
    data_arr[2] = lo|flags|BACKLIGHT|PIN_EN;
    data_arr[3] = lo|flags|BACKLIGHT;
 
    res = HAL_I2C_Master_Transmit(&hi2c1, lcd_addr, data_arr, sizeof(data_arr), HAL_MAX_DELAY);
    HAL_Delay(LCD_DELAY_MS);
    return res;
}
 

any clues ?thanks

11 REPLIES 11

I had been working with the PCF85xx I2C chips years ago, and it were 5V chips then.

Check that your versions do actually work with 3.3V.

I guess you assured there is no address interference between your slave devices.

Read the datasheet(s) carefully, what bus speed this chip (and the others on your bus) support. You need to go for the least common denominator.

And last but not least, check for a proper pull-up resistance. Usually about 2 ..5 kOhm.

Thanks for the reply, I think it's about SCK speed, it's 400Khz on my setting, that chip only can take 100Khz,

I will make experiment on it, but not now, since my board blew up. I'll use STM32F107VCT6 ...

@Community member​ 

Thanks for the reply,

the board is Nucleo152E (main board)

PCF8574 ==> the converter board...