ktownsend wrote on Monday, June 22, 2009:
I managed to get FreeRTOS working properly on a 2148 (I’m still banging my head with the interrupts on the 2478, sigh), and have set up a task to retrieve the activity stats (great new feature by the way!). I’m getting some weird results, though:
Stats 31902 3953
IDLE 4294930780 5317615
LEDs 5146 637
As you can see I only have two tasks running. According to this page (http://www.freertos.org/index.html?http://www.freertos.org/a00021.html), I was expecting activity values in %, and clearly that third column is way out of wack. Do I need to be dividng that third column by total ticks, or something similar, to get a %?
It may also be that I haven’t configured the timer properly as well. This is the code I’m using is as follows, based on an example on the website, but there is one register I wasn’t sure about (see comments below):
// Run Time Statistics (declared in FreeRTOSConfig.h)
#include <lpc214x.h>
#include "FreeRTOS.h"
#include "task.h"
#include "stats/stats.h"
int statsHits = 0;
void statsSetupRunTimeStats( void )
{
// ToDo: Fix this … it isn’t working at present
const unsigned long TCR_COUNT_RESET = 2, CTCR_CTM_TIMER = 0x00, TCR_COUNT_ENABLE = 0x01;
/* Power up and feed the timer with a clock. */
SCB_PCONP |= SCB_PCONP_PCTIM1;
// ??? (this register doesn’t exist on the 2148 … equivalent?
// SCB_PCLKSEL0 = (SCB_PCLKSEL0 & (~(0x3<<2))) | (0x01 << 2);
// ???
/* Reset Timer 0 */
T1_TCR = TCR_COUNT_RESET;
/* Just count up. */
T1_CTCR = CTCR_CTM_TIMER;
/* Prescale to a frequency that is good enough to get a decent resolution,
but not too fast so as to overflow all the time. */
T1_PR = ( configCPU_CLOCK_HZ / 10000UL ) - 1UL;
/* Start the counter. */
T1_TCR = TCR_COUNT_ENABLE;
}
void statsEnable (void)
{
// ToDo
}
void statsDisable (void)
{
// ToDo
}
// LED Task Handler
portTASK_FUNCTION (vStatsTask, pvParameters __attribute__ ((unused)))
{
statsSetupRunTimeStats();
char statsBuffer[100];
const portTickType xStatsDelay = 500 / portTICK_RATE_MS;
for (;
{
vTaskGetRunTimeStats(statsBuffer);
debug_printf(statsBuffer);
statsHits++;
vTaskDelay(xStatsDelay);
}
}