About ADC Keil debugging process STM32F407 exception: do not break into, to solve the EOC flag is cleared inexplicable problems.

Discuss and resolve not enter interrupt, EOC flag is cleared inexplicable issues such as: ADC on Keil debugging process STM32F407 exception

Set up three-way ADC F407 in work in standalone mode, an interrupt is generated after each conversion.
Since the procedure is relatively large, and decided to use debug mode test code and found that programs often can not enter interrupt every single step operation, after starting ADC, EOC identity set; then run step, it EOC flag is automatically cleared , resulting in the debugging process interruption can not enter. The process shown in FIG:

ADC breakpoint debugging
Can be seen from the figure, after starting the conversion ADC1, EOC1 set up. Single step by step as shown:
After running step
As can be seen EOC1 flag is automatically cleared, because the single-step, single-step process did not go into interrupt EOC1 is cleared to 0, the same three ADC is such a situation, it is a problem me a long time to see countless times data Sheet, also suspected a problem interrupted, looked M4 core manuals, watched countless times library code, web search relevant information did not find the problem and find a solution. Even suspected a hardware supply problems, the situation all power measurements again. And if it does not set a breakpoint at this location, set in the interrupt, it will crash situation occurs.
Later, a debugging an ADC find a little better, but still a little problem, and finally do not know how good some of the inexplicable.
In fact, looking at the data sheet during its passage there Figure 3 EOC Cleared
was to see this explanation, I always thought my code have not been to the ADC conversion result in any interruption degrees outside, how it will be cleared up, then somehow good , and do not know what the point of the place, has been grinding my 6 seven hours, finally reluctantly take their children to sleep.
Until the next day, there was such a situation, it is concerned about this issue and want to continue to write down the code, but thought the problem zezheng later, the frequency is higher. I quit after inadvertently debugging, hardware reset freedom to run, the result of the program without any problems, I repeated the test several times are the same, the problem lies: Commissioning, reset automatically run without any problems.
By repeatedly thinking: To be sure, the debugging process EOC flag is cleared, and why? I was behind the program is to debug or not debugging? Suddenly remembered in Figure 3, I debugging process, adding peripherals to see the ADC1, ADC2, ADC3 register, which is in the lower right corner and Figures 1 and 2, it is not to read ADCx-> DR Why? EOC will not lead to clear? So I canceled the ADC1 peripheral view, commissioning, operation shown in Figure 4:
Figure 4 canceled peripheral register ADC1 See
ADC1 found EOC flag will not be cleared up, while the other two will still be cleared, it is certain that: in the debugging process, see ADC value is sent to read the DR register, will certainly lead to ADC the EOC flag. Here also understand why the STM32 to be given C_ADC register is used to view the operating status of each ADC, the original always felt superfluous, but it seems purposeful. So ADC debugging process, see for sure from C_ADC EOC flag in SR register to see, or will cause the program to crash (if your program has to wait for the situation in the EOC).

Released three original articles · won praise 2 · views 78

Guess you like

Origin blog.csdn.net/weixin_42094842/article/details/104494253