I2C Problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-07-03 3:33 AM
I have 2 MCU, one is the STM32F401RE acting as master and the other is STM32G474RE acting as slave, I have kept both the controllers in open drain and pulled up, the slave address is 0x30<<1, I think the data is being transferred because on pressing the reset button on the master, the slave displays this over UART "SLAVE HAL I2C NOT READY" , live expression is not working for me so that was my other option.
My master code is this
- Labels:
-
I2C
-
STM32F4 Series
-
STM32G4 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-07-03 6:28 AM
Hello @Epsilon03,
I quickly looked at your code, here is a list of suggestions/questions for you:
- What displays the master over UART ? Run your Master.c in debug mode to verify the address is well acknowledge and to check the transmission.
- What is the value of aRxBuffer once the code ended ? You can also display it via UART.
- Are you using OpenOCD ? It does not support Live expressions. You need to switch the debug probe to either ST-Link GDB server or J-Link, they both support the feature.
- It might also be a synchronization issue, try to add a little delay to make sure the master transmits once the slave is ready.
Best Regards,
Pierre
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-07-03 6:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-07-03 9:56 PM - edited ‎2023-07-03 10:31 PM
@Pierre_Paris @TDK, I got the live expression working, basically for some reason it was disabled and now I have set it to the highest level of debugging, I also realized that the code is working, once the live expressions allowed me to see what is inside the slave receiving variable.
Also @TDK the "Slave HAL I2C NOT Ready" is only printing on resetting my master board or the slave board.
However there is one issue still remaining, I cannot display the data I received on my slave device, on UART. It's not exiting loop, probably due to the non-blocking feature like TDK mentioned, how do I get around that?
Edit: The data I was sending was bigger than the rxBuffer so the program was waiting for the complete data to be transferred, on shortening the data, UART started displaying the Data .
Thanks for all the help!! @TDK @Pierre_Paris.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-07-05 8:37 AM
Hello @Epsilon03,
The problem must be with I2C and not the UART. I think you aren't exiting the loop because you're sending aTxBuffer with a size of 150 uint8_t but you declare aRxBuffer with a size of 100. The master wait an acknowledge from slave and don't go back in the ready state. The master never terminates the transmission with a STOP condition.
Can you please fix it and tell me if it still gets stuck ?
Best Regards,
Pierre
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.
