cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F401RE: I2C code works only while single stepping in debug mode

ORaji.1
Associate

Good day, I'm trying to interface the STM32F401RE with a DS3231 RTC module. The idea is to read from the time-keeping registers of the RTC module. Based on the code, I decided to set the 'hour' register to 6 and when the register is read, 6 is expected to be read. This code only works while single stepping in debug mode and not at runtime. I don't know why this is happening but if there's something I'm missing or getting wrong, I'd be glad to know.

The source code is in the attached file below.

This discussion is locked. Please start a new topic to ask your question.
1 ACCEPTED SOLUTION

Accepted Solutions
KnarfB
Principal III

Don't want to dig deep into your register level code, just one remark:

if ((I2C1->SR1 & I2C_SR1_TXE)){

This should be a while loop where the code waits spinning in that loop until transmission is completed.

View solution in original post

1 REPLY 1
KnarfB
Principal III

Don't want to dig deep into your register level code, just one remark:

if ((I2C1->SR1 & I2C_SR1_TXE)){

This should be a while loop where the code waits spinning in that loop until transmission is completed.