Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

PIC32configGENERATE_RUN_TIME_STATS ignorance

Posted by Robert H. Oujesky on October 25, 2011
Trying to implement runtime statistics and very ignorant and low blood sugar :( Here is where I am.
First, I modified FreeRTOS.h with the following:

#if ( configGENERATE_RUN_TIME_STATS == 1 )
#defineportALT_GET_RUN_TIME_COUNTER_VALUE 1 //NOT in ebook, but added here... is this right???
/* Neuralog specific */
void vSetupTimerForRunTimeStats(void);

#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vSetupTimerForRunTimeStats()

#define portGET_RUN_TIME_COUNTER_VALUE(ulCountValue)\
{\
extern volatile unsighed long ulTMR2OverflowCount;\
T2CONCLR = T2_ON;\
ulCountValue = (ulTMR2OverflowCount << 16UL);\
ulCountValue |= (unsigned long) ReadTimer2();\
T2CONSET = T2_ON;\
}


/******************/
#ifndef portCONFIGURE_TIMER_FOR_RUN_TIME_STATS
#error If configGENERATE_RUN_TIME_STATS is defined then portCONFIGURE_TIMER_FOR_RUN_TIME_STATS must also be defined. portCONFIGURE_TIMER_FOR_RUN_TIME_STATS should call a port layer function to setup a peripheral timer/counter that can then be used as the run time counter time base.
#endif /* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS */

#ifndef portGET_RUN_TIME_COUNTER_VALUE
#ifndef portALT_GET_RUN_TIME_COUNTER_VALUE
#error If configGENERATE_RUN_TIME_STATS is defined then either portGET_RUN_TIME_COUNTER_VALUE or portALT_GET_RUN_TIME_COUNTER_VALUE must also be defined. See the examples provided and the FreeRTOS web site for more information.
#endif /* portALT_GET_RUN_TIME_COUNTER_VALUE */
#endif /* portGET_RUN_TIME_COUNTER_VALUE */

#endif /* configGENERATE_RUN_TIME_STATS */

when I do this, I get the error:

..\..\Source\tasks.c: In function `vTaskGetRunTimeStats':
..\..\Source\tasks.c:1293: error: called object is not a function
..\..\Source\tasks.c: In function `vTaskSwitchContext':
..\..\Source\tasks.c:1610: error: called object is not a function

I have the PIC32 version of Using the FreeRTOS....

Please point out my idiocracy :)

thanks!

RE: PIC32configGENERATE_RUN_TIME_STATS ignorance

Posted by Richard on October 25, 2011
“//NOT in ebook, but added here... is this right???”


No - you should not be altering FreeRTOS.h at all. That is part of the core kernel code. The macros you need can be added to FreeRTOSConfig.h, which is a file used to tailor the kernel to any particular application.

If you have the PIC32 eBook, then look at section "6.5 Execution Visualization—Run Time Statistics", it describes it, and provides source code for the PIC32.

I presume you have seen this page too? The other thing you can do is look in the FreeRTOS/Demo directory for demos that use run time stats on non-PIC32 devices, just to use as references (you can search/grep for the macro names in the various FreeRTOSConfig.h files).

Regards.

RE: PIC32configGENERATE_RUN_TIME_STATS ignorance

Posted by Erupter on October 25, 2011
In my FreeRTOS.h I put this
#if( configGENERATE_RUN_TIME_STATS )
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() OpenCoreTimer(800); mConfigIntCoreTimer((CT_INT_ON | CT_INT_PRIOR_2 | CT_INT_SUB_PRIOR_0));

//#define portGET_RUN_TIME_COUNTER_VALUE()_CP0_GET_COUNT()
#define portGET_RUN_TIME_COUNTER_VALUE()getStatsTimerCount()

#endif


then in main.c (before any code) I put this

#if( configGENERATE_RUN_TIME_STATS )

unsigned long long StatsTimerCount = 0;

unsigned long long getStatsTimerCount( void )
{
return( StatsTimerCount );
}

void __ISR(_CORE_TIMER_VECTOR, ipl2) CoreTimerHandler(void)
{
// .. things to do

// .. Toggle the LED
StatsTimerCount+=1;
// update the period
UpdateCoreTimer(800);

// clear the interrupt flag
mCTClearIntFlag();
}

#endif


then there is the StatTask definition

static void prvStatsTask( void *pvParameters )
{
int mycnt=0;
for(;;)
{
for( mycnt=0; mycnt<1000; mycnt++)
mybuff[mycnt]=0;
#if( configGENERATE_RUN_TIME_STATS )
vTaskGetRunTimeStats(mybuff);
mycnt=999;
while(mybuff[mycnt]==0)
mycnt--;
if( !(USBUSARTIsTxTrfReady()))
while(!(USBUSARTIsTxTrfReady()))
vTaskDelay(50);

putUSBUSART(mybuff,mycnt);
#endif
Task_1_Enable = 0;
vTaskSuspend( hTask1 );
}
}[/code[

this task is suspended right after creation.
I have used a button to trigger the task execution.
It's designed to execute on request and auto-suspend after completition.
This has worked quite nicely for me.
The pic runs at 80MHz, the scheduler runs at 1ms.

I think it's all you need to have the stats.
I output them on the USB CDC, that's why the scheduler runs at 1ms: it fires the USB poller at that rate.


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner