Hi,
I'd like to measure the performance of some code I'm using, but this
doesn't seem very easy to do with the LPC2138. (using freeRTOS and
Rowley).
In windows I'd use QueryPerformanceCounter() to get a time stamp before
and after. Is there an way to do this with the LPC? Or do I need to set
up a timer interrupt every 1s or something to increment a counter?
Thanks.
LPC2138 performance timer question
Started by ●May 31, 2007
Reply by ●May 31, 20072007-05-31
> -----Original Message-----
> From: l...
> [mailto:l...] On Behalf Of hus_kalydonios
> Sent: 31 May 2007 12:31
> To: l...
> Subject: [lpc2000] LPC2138 performance timer question
>
> Hi,
>
> I'd like to measure the performance of some code I'm using, but this
> doesn't seem very easy to do with the LPC2138. (using freeRTOS and
> Rowley).
>
> In windows I'd use QueryPerformanceCounter() to get a time
> stamp before
> and after. Is there an way to do this with the LPC? Or do I
> need to set
> up a timer interrupt every 1s or something to increment a counter?
>
> Thanks.
You don't need your timer to generate an interrupt, just use a free running
timer with a known frequency. Choose the maximum frequency you can that
will not cause more than a single overflow between two time measurements,
then read the timer count value directly.
FreeRTOS.org V4.3.0 (out next week) has some demos that do exactly this.
Regards,
Richard.
+ http://www.FreeRTOS.org
A free real time kernel for 8, 16 and 32bit systems.
+ http://www.SafeRTOS.com
An IEC 61508 certified real time kernel for safety related systems.
> From: l...
> [mailto:l...] On Behalf Of hus_kalydonios
> Sent: 31 May 2007 12:31
> To: l...
> Subject: [lpc2000] LPC2138 performance timer question
>
> Hi,
>
> I'd like to measure the performance of some code I'm using, but this
> doesn't seem very easy to do with the LPC2138. (using freeRTOS and
> Rowley).
>
> In windows I'd use QueryPerformanceCounter() to get a time
> stamp before
> and after. Is there an way to do this with the LPC? Or do I
> need to set
> up a timer interrupt every 1s or something to increment a counter?
>
> Thanks.
You don't need your timer to generate an interrupt, just use a free running
timer with a known frequency. Choose the maximum frequency you can that
will not cause more than a single overflow between two time measurements,
then read the timer count value directly.
FreeRTOS.org V4.3.0 (out next week) has some demos that do exactly this.
Regards,
Richard.
+ http://www.FreeRTOS.org
A free real time kernel for 8, 16 and 32bit systems.
+ http://www.SafeRTOS.com
An IEC 61508 certified real time kernel for safety related systems.
Reply by ●May 31, 20072007-05-31
--- In l..., "hus_kalydonios"
wrote:
>
> Hi,
>
> I'd like to measure the performance of some code I'm using, but
this
> doesn't seem very easy to do with the LPC2138. (using freeRTOS and
> Rowley).
>
> In windows I'd use QueryPerformanceCounter() to get a time stamp
before
> and after. Is there an way to do this with the LPC? Or do I need to
set
> up a timer interrupt every 1s or something to increment a counter?
>
> Thanks.
>
You could use the CrossWorks Tasking Library.
Leon
wrote:
>
> Hi,
>
> I'd like to measure the performance of some code I'm using, but
this
> doesn't seem very easy to do with the LPC2138. (using freeRTOS and
> Rowley).
>
> In windows I'd use QueryPerformanceCounter() to get a time stamp
before
> and after. Is there an way to do this with the LPC? Or do I need to
set
> up a timer interrupt every 1s or something to increment a counter?
>
> Thanks.
>
You could use the CrossWorks Tasking Library.
Leon
Reply by ●May 31, 20072007-05-31
I did some performance analysis on an LPC2378 core recently by rolling a
very simple profiler.
Look here for more info:
http://www.blisstonia.com/eolson/notes/profile_arm.php
-Ed
very simple profiler.
Look here for more info:
http://www.blisstonia.com/eolson/notes/profile_arm.php
-Ed
Reply by ●May 31, 20072007-05-31
Interesting. Thanks for that. Using that code, can I do this:
T1PR = 1; // prescale divider
T1TCR = (1<<0); // enable the counter
T1CTCR = 0;
to start a free running counter, then poll the value of T1TC before and
after the code I want to time?
With a prescale of 1, at what frequency will the counter increment? I'm
a little confused about the frequencies :s
Thanks again.
T1PR = 1; // prescale divider
T1TCR = (1<<0); // enable the counter
T1CTCR = 0;
to start a free running counter, then poll the value of T1TC before and
after the code I want to time?
With a prescale of 1, at what frequency will the counter increment? I'm
a little confused about the frequencies :s
Thanks again.
Reply by ●May 31, 20072007-05-31
Hey Leon,
I tried with the Tasking Library, but I'm not familiar with it. It
seems incompatible with freeRTOS?
I tried some of the ctl functions but got compiler errors (linker)
despite the includes. I don't know Crossworks well enough...
>
> You could use the CrossWorks Tasking Library.
>
> Leon
>
I tried with the Tasking Library, but I'm not familiar with it. It
seems incompatible with freeRTOS?
I tried some of the ctl functions but got compiler errors (linker)
despite the includes. I don't know Crossworks well enough...
>
> You could use the CrossWorks Tasking Library.
>
> Leon
>
Reply by ●May 31, 20072007-05-31
----- Original Message -----
From: "hus_kalydonios"
To:
Sent: Thursday, May 31, 2007 2:12 PM
Subject: [lpc2000] Re: LPC2138 performance timer question
> Hey Leon,
>
> I tried with the Tasking Library, but I'm not familiar with it. It
> seems incompatible with freeRTOS?
>
> I tried some of the ctl functions but got compiler errors (linker)
> despite the includes. I don't know Crossworks well enough...
I've only used it for a timer function, here are the relevant bits of code
extracted from my program:
#include
//---------------------- Timer 0 interrupt every second -----------------//
static void
timer0ISR(void)
{
IO0PIN ^= (1 << 8); // Toggle LED
T0IR = 0xFF; //Clear the timer 0 interrupt
}
//------------------------- part of initialisation function ----------//
// initialise TIMER0
unsigned long pclk liblpc2000_get_pclk(liblpc2000_get_cclk(OSCILLATOR_CLOCK_FREQUENCY));
T0TCR = 0; /* Reset timer 0 */
T0PR = 0; /* Set the timer 0 prescale counter */
T0MR0 = pclk - 1; /* Set time 0 match register to generate an interrupt at
1Hz */
T0MCR = 3; /* Generate interrupt and reset counter on match */
T0TCR = 1; /* Start timer 0 */
// initialise CTL timer stuff
ctl_set_isr(4, 0, CTL_ISR_TRIGGER_FIXED, timer0ISR, 0);
ctl_unmask_isr(4);
ctl_global_interrupts_enable();
I don't know if it's compatible with FreeRTOS, though.
Leon
From: "hus_kalydonios"
To:
Sent: Thursday, May 31, 2007 2:12 PM
Subject: [lpc2000] Re: LPC2138 performance timer question
> Hey Leon,
>
> I tried with the Tasking Library, but I'm not familiar with it. It
> seems incompatible with freeRTOS?
>
> I tried some of the ctl functions but got compiler errors (linker)
> despite the includes. I don't know Crossworks well enough...
I've only used it for a timer function, here are the relevant bits of code
extracted from my program:
#include
//---------------------- Timer 0 interrupt every second -----------------//
static void
timer0ISR(void)
{
IO0PIN ^= (1 << 8); // Toggle LED
T0IR = 0xFF; //Clear the timer 0 interrupt
}
//------------------------- part of initialisation function ----------//
// initialise TIMER0
unsigned long pclk liblpc2000_get_pclk(liblpc2000_get_cclk(OSCILLATOR_CLOCK_FREQUENCY));
T0TCR = 0; /* Reset timer 0 */
T0PR = 0; /* Set the timer 0 prescale counter */
T0MR0 = pclk - 1; /* Set time 0 match register to generate an interrupt at
1Hz */
T0MCR = 3; /* Generate interrupt and reset counter on match */
T0TCR = 1; /* Start timer 0 */
// initialise CTL timer stuff
ctl_set_isr(4, 0, CTL_ISR_TRIGGER_FIXED, timer0ISR, 0);
ctl_unmask_isr(4);
ctl_global_interrupts_enable();
I don't know if it's compatible with FreeRTOS, though.
Leon