Skip to main content
WM_IR
Associate III
June 1, 2022
Question

STM32F302R8 I2C1 STUCK AT GENERATE START CONDITION

  • June 1, 2022
  • 2 replies
  • 1509 views

Hi, I have a problem where my basic master send data code stuck at the generate start condition function. I am using STM32F302R8,

based on the reference manual, the flow chart stated that SET the I2C_CR2.START.

0693W00000Nr1T2QAJ.jpg 

Then, inside my code, here is my basic code to send the data.

0693W00000Nr1TMQAZ.jpgWhen it goes to inside MasterSendData(), It stuck in the GenerateStartCondition function.

Here is inside the GenerateStartCondition function and the start bit is register number 13.

0693W00000Nr1W6QAJ.jpg0693W00000Nr1WGQAZ.jpgBut, after it finish executing the I2C_GenerateStartCondition, the register I2C_CR2_START does not SET, But, it looping inside the startup file of stm32f302r8 from CopyDataInit to LoopCopyDataInit as shown below.

0693W00000Nr1WzQAJ.jpg 

So, I dont know what is the cause of this problem. Am I missing something in the setup? Hope someone can help me on this

This topic has been closed for replies.

2 replies

waclawek.jan
Super User
June 1, 2022

Isn't there a short, which causes the mcu to reset when it pulls down SDA/SCK?

JW

WM_IR
WM_IRAuthor
Associate III
June 1, 2022

The looping in the startup means the mcu reset? And it is because a short circuit? If there is a short circuit, why it happen during the generate start condition only? Not from the beginning of the program?​

waclawek.jan
Super User
June 1, 2022

That was just a tip. You can check it using an ohmmeter. You can also check it using oscilloscope, measuring NRST, and/or power supply.

JW

WM_IR
WM_IRAuthor
Associate III
June 1, 2022

So the looping in the startup file is indicating what condition usually?​