STM32CubeL0
STM32CubeL0 copied to clipboard
i2c slave mode gets stuck
Describe the set-up
- I'm using a custom board with an STM32L031F4Px
- IDE is stm32Cube Version 1.9.0
- My compiler is gcc-arm-none-eabi-10.3-2021.10
Describe the bug Trying to respond to a read request from a master (configuring the STM32 as slave device) as per https://st.force.com/community/s/article/how-to-create-an-i2c-slave-device-using-the-stm32cube-library. This simply does not work, the only way to get it to work kind of is to reset the I2C peripheral in the transfer complete callback, but this results in loss of data.
Not sure how this is supposed to work, I have enabled interrupts and they are being triggered, but the problem is my SCL line goes down and does not recover. The address is correctly matched but I can't get any further:
How To Reproduce
- Set-up the project as per https://st.force.com/community/s/article/how-to-create-an-i2c-slave-device-using-the-stm32cube-library.
- Use the latest version of this repo as the HAL
- The problem must be somewhere in the stm32l0xx_hal_i2c.c file
- Use case is I2C slave device
Additional context I do not have any proposal for a patch, trying to figure out how to resolve it but I don't fully understand the slave HAL.
Is this related to https://github.com/STMicroelectronics/STM32CubeG0/issues/31 ?
Hello mfiumara,
Thank you for this report. The point you reported is actually related to the How to create an I2C slave device using the STM32Cube Library article and not to the firmware published in this repository (may be a hardware pull-up is missing on I2C pins). Unfortunately, we don't treat aspect related to articles in our GitHub repositories. They are rather treated at the STM32-MCUs dedicated page of the ST Community . Since this issue is not directly related to the STM32Cube firmware but rather to specific application (Aardvark module + STM32CubeMx + article), please allow me then to close this thread.
Thank you for your comprehension.
With regards, Houssine
Hello mfiumara,
Thank you for this report. The point you reported is actually related to the How to create an I2C slave device using the STM32Cube Library article and not to the firmware published in this repository (may be a hardware pull-up is missing on I2C pins).
Unfortunately, we don't treat aspect related to articles in our GitHub repositories. They are rather treated at the STM32-MCUs dedicated page of the ST Community .
Since this issue is not directly related to the STM32Cube firmware but rather to specific application (Aardvark module + STM32CubeMx + article), please allow me then to close this thread.
Thank you for your comprehension.
With regards,
Houssine
Hi Houssine,
I am 100% sure that this is a bug in the HAL which I have now resolved by implementing the i2c slave mode myself following the stm32 0 series reference manual (writing registers directly).
I hope you can take this issue more seriously than just waving it off as an article inaccuracy or a hardware setup problem (pull up missing, really?). I would advise to leave this ticket open until it is actually resolved in case someone else spends weeks on figuring out what's going on in their implementation.
If you're low on resources I'd gladly help by sharing the basis of a working implementation.
Best regards,
Mattia
@mfiumara I have been struggling for AGES with the G0 I2C implementation. I know 100% there is no issue with my hardware setup. What is happening is that the first HAL_I2C_Slave_Transmit_IT call works, and the second one never completes. It's definitely a bug with the HAL code itself, and all my attempts to report this issue have gone ignored by ST. If you have any tips about how to fix it I'd love to know, thanks!
This also seems related potentially: https://github.com/STMicroelectronics/STM32CubeF4/issues/76
Hello @Mfiumara We have followed the steps you have described to reproduce the issue and we did not get the same behavior you are having. The salve is correctly responding as shown in the following results :
For a better analysis of the problem would you please provide us with the project you have used to reproduce the issue. Would you also confirm that you are using the latest version of the STM32CubeL0 (V1.12.1).
With regards,
Hey as reported in the original ticket I used stm32Cube Version 1.9.0. I imagine it was fixed in the newer stm32cube release then?