STM32 personal notes – program run and fly

Some of the notes come from the public account of “STM32 [Embedded] Development”.

Program running score

Number out of bounds/overflow

Phenomenon: When the microcontroller program runs in the function, it always runs to the end of the function, and when it wants to jump out of the function, the program runs away.

Cause: Array out of range (array overflow). like

uint8_t ucDataBuff[10]={0};

ucDataBuff[10]=0x1;

Solution: If when debugging the program, it is found that the program always runs away when the function is executed. In most cases, an array out-of-bounds (array overflow) error occurs. Carefully check whether the array called in the function has an out-of-bounds (overflow) situation. .

Missing interrupt service function

Phenomenon: The program always runs away during the running process.

Reason: An interrupt is turned on in the program, but there is no corresponding interrupt service routine, so that after the interrupt occurs, the entry of the interrupt service routine cannot be found, resulting in the program running away.

Solution: Check whether there is an interrupt turned on in the program, but there is no corresponding interrupt service routine.

watchdog reset

Phenomenon: When executing a relatively time-consuming program, the program runs away and always jumps to the reset position.

Reason: The watchdog is used in the program, but the dog is not fed in time, which causes the watchdog to reset and the program jumps directly to the reset position.

Solution: According to the running time of the program, especially the running time of the most time-consuming part of the program must be calculated, and then accurately set the reset time of the watchdog, and feed the dog regularly. Especially if there is an infinite loop, be sure to remember to feed the dog in the infinite loop.

Leave a Comment

Your email address will not be published. Required fields are marked *