2021-08-09 08:24 PM
As figure shows:
I am using the STM32CUBEIDE V1.7, STM32F407 discovery board. Any help is appreciated.
Thanks,
Xiankun
Solved! Go to Solution.
2021-08-11 05:49 PM
Hi Tesla and TDK,
Thanks very much for your kind help.
After debugging, I found out the reason is that I manually changed the SP register's value before entering this routine.
I didn't exactly understand why this will cause the weird behavior. As I thought the local variable "i" is in local stack, so the change of SP before calling this routine will have no influence on the behavior of this routine. But obviously carelessly change SP is dangerous.
Thanks
Xiankun
2021-08-09 08:49 PM
Are you using the optimizer? Might want to try with it disabled for the function.
Try looking at the code generated by the compiler, probably holding variable in a register
2021-08-10 06:20 AM
It's probably just not showing exactly what's going on. Note that tid can't be correct either, since it should be < 5.
Defining variables as volatile can stop optimization.
2021-08-11 05:49 PM
Hi Tesla and TDK,
Thanks very much for your kind help.
After debugging, I found out the reason is that I manually changed the SP register's value before entering this routine.
I didn't exactly understand why this will cause the weird behavior. As I thought the local variable "i" is in local stack, so the change of SP before calling this routine will have no influence on the behavior of this routine. But obviously carelessly change SP is dangerous.
Thanks
Xiankun