Use vTaskGetRunTimeStats with codewarrior

chafiqsakouat wrote on Wednesday, April 11, 2012:

Hello,
I use FreeRTOS source 7.1.0 with Frescale IDE codewarrior special Edition, so i dont have any operating system for this version. But i has opensource 7.1.0 that i add to my project. It s works correctly.
My device is MC9S12XEQ512
I have two timer one of them is used to generate tickcount for RTOS and the second is used  to calculate  CPU charge using vTaskGetRunTimeStats.
I set in FreeRtosConfig.h :
#define configGENERATE_RUN_TIME_STATS 1
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() Timer_GetRunTime_OnInterrupt()
#define portGET_RUN_TIME_COUNTER_VALUE () ulHighFrequencyTimerTicks

the Timer_GetRunTime_OnInterrupt is a Interrupt for my second timer :

#pragma CODE_SEG __NEAR_SEG NON_BANKED
ISR(Timer_GetRunTime_Interrupt)
{
  PITTF = 0x04U;                       /* Reset interrupt request flag */
  Timer_GetRunTime_OnInterrupt();      /* Invoke user event */
}

#pragma CODE_SEG Timer_GetRunTime_CODE

the event “Timer_GetRunTime_OnInterrupt()” is defined into events.c as follow :

void Timer_GetRunTime_OnInterrupt(void)
{
  /* Write your code here … */
  ulHighFrequencyTimerTicks++;
  }

when i compile the “task. c” i have some errors

Thank you for your help

xz8987f wrote on Wednesday, April 11, 2012:

Hello,
could you post the kind of error messages you see, and which version of CodeWarrior you are using?

thanks!

xz8987f wrote on Wednesday, April 11, 2012:

Hello,
FYI, I’m using the port described in
http://mcuoneclipse.wordpress.com/2012/02/11/back-to-classic-freertos-for-freescale-s12x/
with CodeWarrior for MCU 5.1 (classic, not eclipse). I have performance counter enabled, and it works for me just fine.

chafiqsakouat wrote on Wednesday, April 11, 2012:

Hello xz897f,
I use CodeWarrior V5.1 special Edition without any operatin system.
the erros are :
C2450: Expected   IDENT char cont double enum float int long short sigend struct union unsigend void volatile
and some error
the cursor is set in the line itnt task.c
ulTotalRunTime =  portGET_RUN_TIME_COUNTER_VALUE(); 

xz8987f wrote on Wednesday, April 11, 2012:

Hello,
as the error is for the macro portGET_RUN_TIME_COUNTER_VALUE(), which is using ulHighFrequencyTimerTicks:
can you make sure that task.c includes the header file which contains ulHighFrequencyTimerTicks?

I think that you are missing to include the declaration for ulHighFrequencyTimerTicks.

chafiqsakouat wrote on Wednesday, April 11, 2012:

Hello,
I has include the header file which contains ulHighFrequencyTimerTicks, it s name is “Events.h” and ulHighFrequencyTimerTicks is decalared as extern.  

xz8987f wrote on Thursday, April 12, 2012:

Hello,
well, then it is hard to tell what the problem could be. Maybe attach/provide a link to your project and I can have a look.

chafiqsakouat wrote on Tuesday, April 24, 2012:

Hello,
Finaly i have find the problem, it s came frome my macro i have written :
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS Timer_GetRunTime_OnInterrupt()
#define portGET_RUN_TIME_COUNTER_VALUE  ulHighFrequencyTimerTicks
and not
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() Timer_GetRunTime_OnInterrupt()
#define portGET_RUN_TIME_COUNTER_VALUE () ulHighFrequencyTimerTicks

i checked the function it works corectly but i have a problem in my timing when i add the second counter my tasks are not accurate it is normal?