2023-12-19 11:12 PM - edited 2023-12-20 05:45 AM
I am using STM32G050 and I also tried with STM32L476. I am transmitting data as an I2C Slave using STM-HAL. However, when I use HAL_I2C_EnableListen_IT, the transmission is an error. I can't read values and see the logic analyzer. HAL_I2C_DisableListen_IT allows successful data transmission. I am trying to understand the underlying reasons for this behavior. Why I can't transmit values?
uint8_t packed1[10] = { 0xAA, 0x01, 0x07, 0x01, 0x12, 0x55, 0x12, 0x01, 0xAA, 0x2B };
uint8_t packed2[10] = { 0xBB, 0x01, 0x07, 0x01, 0x12, 0x55, 0x12, 0x01, 0xAA, 0x2B };
HAL_I2C_EnableListen_IT(&hi2c2);
HAL_I2C_Slave_Transmit(&hi2c2, packed1, 10, HAL_MAX_DELAY);
HAL_Delay(300);
HAL_I2C_DisableListen_IT(&hi2c2);
HAL_I2C_Slave_Transmit(&hi2c2, packed2, 10, HAL_MAX_DELAY);
HAL_Delay(300);
Solved! Go to Solution.
2023-12-20 05:49 AM
You're not using the library according to the instructions. Don't call HAL_I2C_EnableListen_IT when you're using blocking transfer functions.
*** Polling mode IO operation ***
=================================
[..]
(+) Transmit in master mode an amount of data in blocking mode using @ref HAL_I2C_Master_Transmit()
(+) Receive in master mode an amount of data in blocking mode using @ref HAL_I2C_Master_Receive()
(+) Transmit in slave mode an amount of data in blocking mode using @ref HAL_I2C_Slave_Transmit()
(+) Receive in slave mode an amount of data in blocking mode using @ref HAL_I2C_Slave_Receive()
2023-12-20 05:49 AM
You're not using the library according to the instructions. Don't call HAL_I2C_EnableListen_IT when you're using blocking transfer functions.
*** Polling mode IO operation ***
=================================
[..]
(+) Transmit in master mode an amount of data in blocking mode using @ref HAL_I2C_Master_Transmit()
(+) Receive in master mode an amount of data in blocking mode using @ref HAL_I2C_Master_Receive()
(+) Transmit in slave mode an amount of data in blocking mode using @ref HAL_I2C_Slave_Transmit()
(+) Receive in slave mode an amount of data in blocking mode using @ref HAL_I2C_Slave_Receive()
2023-12-21 12:43 AM - edited 2023-12-21 12:52 AM
Thank you for answering.
When I transmit it like this I can't transmit it again
2023-12-21 06:57 AM
Why are you calling HAL_I2C_EnableListen_IT?
Perhaps go off of a known working example:
2023-12-22 03:53 AM - edited 2023-12-22 03:54 AM
b
2023-12-22 06:10 AM
@TDKI figured out my problem. I took the structure here as a reference.