2024-05-07 03:57 AM
Hi all,
I have a doubt regarding the while(1) loop in c based program for STM32MCU for both keil and STM32cubeIDE softwares.
How can we get the cycle time of while(1) loop?
I have program code for STM32g0 series of MCU and couldn't evaluate the cycle time of while(1) from it.
Please help asap.
Regards
Solved! Go to Solution.
2024-05-07 04:22 AM
The simplest and most practical way how to measure "loop speed" is to toggle a GPIO pin in that loop, and observe using oscilloscope/logic analyzer.
You can also start a software or hardware timer at one point of the loop body and stop it in the next pass through that same point; the number of counts of that timer gives you then execution time of one iteration of the loop. However, you need somehow to visualize the measured value, either using some communication link like UART to a PC, or on a display, or using debugger, etc.
JW
2024-05-07 04:17 AM
@EktaMalia wrote:How can we get the cycle time of while(1) loop
Simplest way is probably to toggle a pin at the top (or bottom) of the loop, and then watch it on an oscilloscope.
2024-05-07 04:22 AM
The simplest and most practical way how to measure "loop speed" is to toggle a GPIO pin in that loop, and observe using oscilloscope/logic analyzer.
You can also start a software or hardware timer at one point of the loop body and stop it in the next pass through that same point; the number of counts of that timer gives you then execution time of one iteration of the loop. However, you need somehow to visualize the measured value, either using some communication link like UART to a PC, or on a display, or using debugger, etc.
JW