evaluate the execution time

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

Moderators: barthess, RoccoMarco

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

evaluate the execution time

Postby yushanh » Tue Mar 04, 2014 10:58 pm

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

Postby yushanh » Wed Mar 05, 2014 12:42 am

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
Location: Middle Georgia, USA
Contact:

Re: evaluate the execution time

Postby jscott » Wed Mar 05, 2014 2:17 am

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: 13012
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 745 times
Been thanked: 621 times
Contact:

Re: evaluate the execution time

Postby Giovanni » Wed Mar 05, 2014 9:15 am

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

Postby Marco » Wed Mar 05, 2014 2:39 pm

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

Postby yushanh » Wed Mar 05, 2014 8:10 pm

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! :)


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 5 guests