2019-07-08 08:26 AM
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
2019-07-08 09:23 AM
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.
2019-07-08 09:33 AM
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...
2019-07-08 06:38 PM
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...
2019-07-08 06:40 PM
The other 3 Slaves are working ok, but only this one not gave a good response ??
2019-07-08 06:48 PM
Now , the power supply burned the regulator on nucleo, I got to change the transistor again 2N3055.....:(
2019-07-08 07:15 PM
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
2019-07-08 09:24 PM
LCD16x2 HD47480 from Hitachi address =4E
2019-07-09 12:08 AM
You might want to post a schematic of the I2C portion of your circuit
2019-07-09 05:52 AM
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