diff --git a/source/shoh/freertos/FreeRTOSConfig.h b/source/shoh/freertos/FreeRTOSConfig.h index ec2abf9..da1e190 100644 --- a/source/shoh/freertos/FreeRTOSConfig.h +++ b/source/shoh/freertos/FreeRTOSConfig.h @@ -91,7 +91,8 @@ #define configUSE_MALLOC_FAILED_HOOK 1 #define configUSE_APPLICATION_TASK_TAG 0 #define configUSE_COUNTING_SEMAPHORES 1 -#define configGENERATE_RUN_TIME_STATS 0 +#define configGENERATE_RUN_TIME_STATS 1 +#define configRECORD_STACK_HIGH_ADDRESS 1 #define configUSE_TICKLESS_IDLE 1 @@ -119,6 +120,16 @@ to exclude the API function. */ #define INCLUDE_vTaskDelay 1 #define INCLUDE_xTaskGetCurrentTaskHandle 1 +/* NOTE: we need to provide implementation of vConfigureTimerForRunTimeStats() + * It is called to set up high resolution timer that is needed for accurate runtime + * measurement. I assume that we use LPC_SCT1 in unified mode so this function + * must set up LPC_SCT1. + */ +void vConfigureTimerForRunTimeStats(void); +#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vConfigureTimerForRunTimeStats() +/* The value is read directly from the counter register for efficiency and low overhead. */ +#define portGET_RUN_TIME_COUNTER_VALUE() LPC_SCT1->COUNT_U + /* Cortex-M specific definitions. */ #ifdef __NVIC_PRIO_BITS /* __BVIC_PRIO_BITS will be specified when CMSIS is being used. */ diff --git a/source/shoh/src/main.cpp b/source/shoh/src/main.cpp index 8495385..f054cb4 100644 --- a/source/shoh/src/main.cpp +++ b/source/shoh/src/main.cpp @@ -29,3 +29,16 @@ int main(void) return 1; } + +extern "C" +{ + void + vConfigureTimerForRunTimeStats (void) + { + Chip_SCT_Init (LPC_SCT1); + LPC_SCT1->CONFIG = SCT_CONFIG_32BIT_COUNTER; + LPC_SCT1->CTRL_U = SCT_CTRL_PRE_L (255) + | SCT_CTRL_CLRCTR_L; // set prescaler to 256 (255 + + // 1), and start timer + } +}