Skip to main content
Associate
July 25, 2023
Question

STM32 as I2C slave: Data recieved LED not working

  • July 25, 2023
  • 1 reply
  • 1437 views

I'm trying to setup an STM32F401RBT as an I2C slave with an Arduino Uno as the master. The Arduino code looks as follows: 

SwissGnome_0-1690267011304.png

I'm simply trying to transmit "3". The STM32 side looks like this: 

SwissGnome_1-1690267097195.png

I use these three callback functions to manage the data. I am successfully recieving the correct number on the STM32 however the sub routine in the HAL_I2C_SlaveRxCpltCallback is not working. I'm trying to light up and LED for 100ms and off again for 100ms however the LED is constantly on and doesn't blink. Also, once the LED first turns on the STM32 ignores all other communication from the Arduino as it doesn't send an ACK bit on the next transaction. So somehow when it goes into this sub routine it freezes and doesn't do anything. Any ideas as to what the issue is? Thanks.

This topic has been closed for replies.

1 reply

Jaroslav JANOS
ST Employee
July 28, 2023

Hello @Swiss Gnome,

with the given information it is just guessing. I suggest you to check your wiring (proper pull-ups), lower the speed to e. g. 1 kHz, and/or check the signals on scope. Also, have you checked for bus errors on STM32 side? How is the STM32 I2C peripheral configured? Is it even configured to send those ACKs? How is the LED/GPIO configured, to be ON after initialization? Or is it OFF in the beginning, then turned ON by the subroutine, and during the delay the execution ends in e. g. HardFault?

BR,
Jaroslav

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.