2023-03-14 09:00 AM
I am struggling to find working examples to work with FreeRTOS in an interrupt mode.
I use the function HAL_I2C_Slave_Transmit_IT() This enables the interrupt as well as setting up the data.
It works to a point, then the remote Master send a Nak and 8 bytes which then fires the Error interrupt.
However the Write address and the Subaddress is sent there is an issue. The top trace in the waveform below indicated where the interrupt fires. What is most notable that the second firing is a result of a RXNE bit being set. As this bit is never cleared by a read from the data register in the HAL library the interrupt fires again about 200 times until a read address is received.
I feel that is an issue with the stm32f4xx_hal_i2c.c library?
There doesn't seem to be a wealth of slave I2C examples for the STM32F4 series. I think I know what I am doing wrong, but either way this behaviour is not ideal. The byte should at least be read and an error indicated in some way.
Solved! Go to Solution.
2023-03-16 07:27 AM
Many thanks for the interest. This was just the Event interrupt firing.
I've since scrapped using the HAL libraries for this slave I2C implementation and use my own state-machine function. That way the slave acts autonomously independent of FreeRTOS and HAL libraries.
Sorry, I can't now reproduce the issue. There are a number of functions to enable interrupts according to Master/Slave Receive/Transmit intention including listen functions. I can only presume the RXNE interrupt was enabled but the byte wasn't being read due to the combination of a Slave_RX and Listen function calls.
I have since moved on, and I implement a very simple state machine in the I2C_EV interrupt. A scope was essential to show the I2C signals as well as a test output pin to show when the interrupt fires.
2023-03-16 07:02 AM
Hello @Community member ,
Could you please share more details ( STM32F4 cubeFW version , how to reproduce this issue ..)
Foued
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-03-16 07:27 AM
Many thanks for the interest. This was just the Event interrupt firing.
I've since scrapped using the HAL libraries for this slave I2C implementation and use my own state-machine function. That way the slave acts autonomously independent of FreeRTOS and HAL libraries.
Sorry, I can't now reproduce the issue. There are a number of functions to enable interrupts according to Master/Slave Receive/Transmit intention including listen functions. I can only presume the RXNE interrupt was enabled but the byte wasn't being read due to the combination of a Slave_RX and Listen function calls.
I have since moved on, and I implement a very simple state machine in the I2C_EV interrupt. A scope was essential to show the I2C signals as well as a test output pin to show when the interrupt fires.