Skip to main content
antonius
Associate III
July 8, 2019
Question

4 devices on I2C ?

  • July 8, 2019
  • 11 replies
  • 1904 views

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

This topic has been closed for replies.

11 replies

Tesla DeLorean
Guru
July 8, 2019

Perhaps read the datasheet/manual for the display? No idea about what you're using.

If the I2C controller on the LCD has multiple registers, you may need to use the addressing form of I2C Write.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
S.Ma
Principal
July 8, 2019

you should read the datasheet of all 4 slave products, check what is the I2C operating voltage and check their slave address. Make sure they are unique.

Usually I2C bus for STM32 is 5V tolerant GPIO, so you can connect 5V pull-ups if necessary. Check each slave operating voltage to make sure all are compatible...

antonius
antoniusAuthor
Associate III
July 9, 2019

the chipset for I2C to LCD is http://www.ti.com/lit/ds/symlink/pcf8574.pdf

PCF8574, that's what I can see on the board, I've been reading it ...

I reckon it's 5V tolerant...

Tesla DeLorean
Guru
July 9, 2019

So an IO Expander

Any detail of how you have the display wired to this? And specification for the display, and powering of either?

What address are you providing to your LCD_SendInternal() function?

>>PCF8574, that's what I can see on the board

What board?

You make this stuff so very hard to debug/diagnose with your poor presentation

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
antonius
antoniusAuthor
Associate III
July 9, 2019

The other 3 Slaves are working ok, but only this one not gave a good response ??

antonius
antoniusAuthor
Associate III
July 9, 2019

Now , the power supply burned the regulator on nucleo, I got to change the transistor again 2N3055.....:(

Gudgel.boB
Senior
July 9, 2019

You might want to post a schematic of the I2C portion of your circuit

Jack Peacock_2
Associate II
July 9, 2019

A common problem when the I2C bus hangs is that the target peripheral holds the STOP bit, locking the bus. I've seen this happen when the peripheral gets a bad command or the command fails in some way, leaving the bus unavailable. Check your SDA and SCL lines when this happens. You can usually clear it if the peripheral has a reset, otherwise forcing out 9+ clocks in GPIO mode may sometimes clear it. Unfortunately I've also come across some I2C peripherals that require a power cycle to clear the bus when this happens.

Jack Peacock