cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 microcontroller clock

EktaMalia
Associate

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

 

1 ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

2 REPLIES 2
Andrew Neil
Evangelist III

@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.

 

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