cancel
Showing results for 
Search instead for 
Did you mean: 

System counter

com
Associate II
Posted on September 18, 2008 at 13:18

System counter

5 REPLIES 5
com
Associate II
Posted on May 17, 2011 at 09:55

Hello:

I'm evaluating potential of a STR912 microprocessor over a IAR STR912-SK evaluation board, together with IAR Embedded Workbench ID.

I've programmed some rutines and I want to know exactly these rutines load (how many processor ticks) on the entire system, and to do it in runtime, not to use any of external profiler.

I'm looking for a processor internal counter that give me information about ticks counter, but I don't find it.

Only solution I try is to use one timer (TIM0) to generate an interrupt every interval (I test to generate ticks/increment my process counter every 100us). It works fine but I need more resolution, would be fine 1us, but of course I'm not going to generate interrupts every 1us because it'll overload the system.

Do you have a better idea??

Thanks and best regards to everybody!!!

dhoyen
Associate II
Posted on May 17, 2011 at 09:55

Hi,

Because i don't know if you are using a RTOS like FreeRTOS or ECos,

I will take in account you are not using.

The maximum frequency, as input clock for the timer is 48 Mhz, means you should be able to measure a quantum time of 20 nsec. (of course, prescaler will be 0).

Init and configure your timer,

Start It (Timer)

Execute your work (maybe with a loop if your work is too light)

Stop It (Timer)

and read the value from the register : TIMx->CTNR

Don't put an interrupt because the latency could be important, and a STR9 can difficulty generate more than 100-200 KHz of interrupt...

Be sure your timer haven't done a overflow from 0xFFFF to 0x0000 (maybe install an interrupt with a debug breakpoint could be a good idea to detect it). Be careful, according to the documentation, the timer start with 0xFFFC)

My feeling about the STR9 is : This is a really powerful processor..

I m using it with a RTOS, some 32K sample at 1 Mhz frequemncy with DMA, SD card, RS232... and he does the job marvelously...

Regards.

damien

[ This message was edited by: dhoyen on 18-09-2008 12:35 ]

[ This message was edited by: dhoyen on 18-09-2008 12:37 ]

com
Associate II
Posted on May 17, 2011 at 09:55

Hi Damien:

Thanks a lot for your answer!

As you correctly think, I'm not use any RTOS, but I'm thinking seriously about it.

What do you suggest me???

I'll use your prupose for measuring code load.

Anyway it would be very interesting for other pruposes if I'm able to generate a System Ticks Counter with a high precission, about 1us, but I don't think using timers and interrupts would be a good idea.

Do you know if is it any register (just defined or must configure) where I can read PLL ticks counter ???

Best regards and thanks again!!!

Xabi

daniel8
Associate II
Posted on May 17, 2011 at 09:55

There are a few ways I would approach that problem.

Setup the timer for no prescaler, so you can indeed get close to 20ns resolution. Read the timer value, store it at the beginning of your code,

then read it again at the end, and that will tell you the time difference.

The problem with interrupts is you will have latencies that will be in the microsecond range, and wont give you enough resolution.

Another way would be to use the GPIO to set a pin high, then set the pin low, and measure the time with a scope.

Lastly, if the code does not have too many conditional jumps, you could see what the code compiled to in assembly, figure out how many instructions and figure out the time that way.

Daniel

dhoyen
Associate II
Posted on May 17, 2011 at 09:55

Hi all,

I completely agree with Daniel, his method is maybe simpler than mine.

For your timer : Keep in mind, in all case, you will not be able to generate 1 million interrupt per second, and never with stability (worse if you use a RTOS which will disabled interrupt during tiny time slot)

Read PLL tick: Impossible or at least, never look.

Solution : You can do it really easily with a timer generate a DMA call at 1 Mhz and put / read something to / from your memory.

What is the goal of your 1usec timer ?

For a RTOS choice, in fact, I'm using a fully open source ToolChain:

1) FreeRTOS as RTOS : excellent support via the forum, a really good job have been done there, in documentation also... I recommand greatly FreeRTOS.

PS:the port for STR912 is available for IAR as GCC.

Another RTOS, OpenSource could be eCos, i have never used it.

2) YAGARTO connected with Eclipse as toolchain (GCC) :

This toolchain: Yagarto seems really 'mature'(by mature: i mean stable, not out of date ;-). Eclipse provide the graphical IDE.

As with FreeRTOS, plenty of documentation, really good support via the forum, the STR91x is fairly well supported.

3) OpenOCD and a Olimex JTAG-USB-OCD debugger / programmer (Cost: 50£):

No problem here...

Regards.