evaluate the execution time

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
yushanh
Posts: 31
Joined: Mon Jul 29, 2013 6:23 pm

evaluate the execution time

Post by yushanh »

Hi all,

I wonder if anyone could suggest some methods to evaluate the program execution time? I have a project with an ISR which has some SPI transactions. When I checked my scope it took around half second for an ISR, which takes really long time for the SPI clock rate of 16 MHz... I'm trying to find some ways to debug and narrow down the problem. Is there any way to get the current kernel time stamp for debugging purpose? Or any debugging method is welcomed... Thanks a lot. :D

~S
yushanh
Posts: 31
Joined: Mon Jul 29, 2013 6:23 pm

Re: evaluate the execution time

Post by yushanh »

I found some discussions on the forum that SysTick could be used to evaluate time. But in the current kernel, CH_FREQUENCY has been set to 1000, which I assume is 1 ms for each SysTick? How could be measure the time of micro-second level?

Thanks!

~S
jscott
Posts: 129
Joined: Tue Jul 03, 2012 3:50 pm

Re: evaluate the execution time

Post by jscott »

You can use halGetCounterValue()

You can find more information at:

http://chibios.sourceforge.net/html/gro ... a55b7fd74c

-John Scott
User avatar
Giovanni
Site Admin
Posts: 14892
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: evaluate the execution time

Post by Giovanni »

Please also enable the state checker in chconf.h, such a long time makes me think you are doing something wrong somewhere.

Giovanni
Marco
Posts: 128
Joined: Tue Apr 16, 2013 8:22 pm
Has thanked: 4 times
Been thanked: 11 times

Re: evaluate the execution time

Post by Marco »

Maybe you should do SPI transactions in a seperate thread instead of in the ISR?
yushanh
Posts: 31
Joined: Mon Jul 29, 2013 6:23 pm

Re: evaluate the execution time

Post by yushanh »

Yes, I woke up the thread for SPI transaction in ISR.

Thanks to jscott for pointing out the halGetCounterValue(). That really helped me to narrow down my problem. The reason was that I had an empty while loop in my main thread, which kept it really really really busy... :roll: After I added a sleep function there, the SPI performance becomes much much much better! Thanks for you guys' help! :)
Post Reply