diptopal wrote on Thursday, August 22, 2013:
Yes I am referring to the demo referenced in the page I linked. Here is my setting in FreeRTOSConfig.h relevant to this
#define configGENERATE_RUN_TIME_STATS 1
.
.
.
extern void vConfigureTimerForRunTimeStats( void );
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vConfigureTimerForRunTimeStats()
#define portGET_RUN_TIME_COUNTER_VALUE() LPC_TIM0->TC
In the main program, this is the function to set up Timer0, same as the port I am using as reference, GCC RedSuite for LPC1768.
**void vConfigureTimerForRunTimeStats( void )
{
const unsigned long TCR_COUNT_RESET = 2, CTCR_CTM_TIMER = 0x00, TCR_COUNT_ENABLE = 0x01;
/* This function configures a timer that is used as the time base when
collecting run time statistical information - basically the percentage
of CPU time that each task is utilising. It is called automatically when
the scheduler is started (assuming configGENERATE_RUN_TIME_STATS is set
to 1). */
LPC_printf(“Configure Timer called\r\n”);
/* Power up and feed the timer. */
LPC_SC->PCONP |= 0x02UL;
LPC_SC->PCLKSEL0 = (LPC_SC->PCLKSEL0 & (~(0x3<<2))) | (0x01 << 2);
/* Reset Timer 0 */
LPC_TIM0->TCR = TCR_COUNT_RESET;
/* Just count up. */
LPC_TIM0->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. */
LPC_TIM0->PR = ( configCPU_CLOCK_HZ / 10000UL ) - 1UL;
/* Start the counter. */
LPC_TIM0->TCR = TCR_COUNT_ENABLE;
}**
I have declared the buffer like this in the main program,
char *stats ;
Now when I am calling the vTaskGetRunTimeStats from one of the tasks I have created, the execution hangs i.e. the printing stops in the console. Normally in the console, the way I have written the code, it prints out all the tasks. I am calling vTaskGetRunTimeStats like this
**void vErrorChecks7( void * pvParameters )
{
int i ;
for (; {
if( xSemaphoreTake( xSemaphore, ( portTickType ) 100 ) == pdTRUE ) {
LPC_printf(" Task 8 running now and the task stats is \n\r " );
vTaskGetRunTimeStats(stats);
//LPC_printf("%s", stats);
}
else {
LPC_printf(“Task 8 Could not get semaphore\n\r”);
}
xSemaphoreGive( xSemaphore );
vTaskDelay(8000) ;
}
}**
What am I doing wrong ?
I will also look at the link provided for uxTaskGetSystemState().