ose wrote on Friday, May 18, 2018:
Hi,
I have been trying to calculate the execution time of a task(led blinking) and i have followed the instructions here https://www.freertos.org/rtos-run-time-stats.html and also tried to understand the demo exmaples there and impliment it but i am using a different MCU(arduino uno) so i cant edit the demo for mine. I have also read how to use the vTaskGetRunTimeStats https://www.freertos.org/a00021.html#vTaskGetRunTimeStats and i have followed the instruction to the best of my undertstanding.
But i have been on this for the past three weeks and i have still not been able to get the task execution time showing in tabular form. I read some more and i think i will have to do some stuffs with ip address and some stuffs that seem to much for me as a beginner.
Please is there another way to get the task execution time or is there a demo for the Atmega328in regards calculating task execution time because i tried searching for but didnt see. Its possible i didnt look in the right place.
Any kind of suggestion will be great.
Below is my main.c++ and Freertosconfig.h, what i have done so far following the instructions and demo examples here https://www.freertos.org/rtos-run-time-stats.html
#include "FreeRTOS.h" #include "task.h" #include "queue.h" #include "semphr.h" #include #include #include #include #include static void TaskBlinkMainLED(void* pvParameters); //----------------------------------------------------------- int main() { xTaskCreate(TaskBlinkGreenLED, (const portCHAR*) "GreenLED", 100, NULL, 1, NULL); xTaskCreate(TaskBlinkMainLED, (const portCHAR*) "ExtraLED", 100, NULL, 2, NULL); vTaskStartScheduler(); for (;;) ;; return 0; } static void TaskBlinkMainLED(void* pvParameters) { char bufptr1[150]; //set pin 5 of PORTB for output DDRB |= _BV(DDB5); TickType_t xLastWakeTime = xTaskGetTickCount(); for(int x = 0; x < 5 ; x++ ){ // LED on PORTB |= _BV(PORTB5); vTaskDelayUntil(&xLastWakeTime, (1000/ portTICK_PERIOD_MS)); // LED off PORTB &= ~_BV(PORTB5); vTaskDelayUntil(&xLastWakeTime, (1000 / portTICK_PERIOD_MS)); } vTaskGetRunTimeStats(bufptr1); vTaskDelete(NULL); } //----------------------------------------------------------- void vApplicationStackOverflowHook(TaskHandle_t xTask, portCHAR* pcTaskName) { // main LED on DDRB |= _BV(DDB5); PORTB |= _BV(PORTB5); // die while (true) { PORTB |= _BV(PORTB5); _delay_ms(250); PORTB &= ~_BV(PORTB5); _delay_ms(250); } } void vConfigureTimerForRunTimeStats(void){ const unsigned long TCR_COUNT_RESET=2, CTCR_CTM_TIMER= 0x00, TCR_COUNT_ENABLE=0x01; EECR|= 0x02UL; TCCR1B = (TCCR1B & (~(0x3<<2))) | (0x01 << 2); TCNT0=TCR_COUNT_RESET; TCNT0=CTCR_CTM_TIMER; CLKPR=(configCPU_CLOCK_HZ/10000UL) - 1UL; TCNT0=TCR_COUNT_ENABLE; } #define configUSE_APPLICATION_TASK_TAG 1 #define configUSE_PREEMPTION 1 #define configUSE_IDLE_HOOK 0 #define configUSE_TICK_HOOK 0 #define configCPU_CLOCK_HZ ( ( unsigned long ) 8000000 ) #define configTICK_RATE_HZ ( ( TickType_t ) 1000 ) #define configMAX_PRIORITIES ( 4 ) #define configMINIMAL_STACK_SIZE ( ( unsigned short ) 85 ) #define configTOTAL_HEAP_SIZE ( (size_t ) ( 1500 ) ) #define configMAX_TASK_NAME_LEN ( 8 ) #define configUSE_TRACE_FACILITY 1 #define configUSE_16_BIT_TICKS 1 #define configIDLE_SHOULD_YIELD 1 #define configGENERATE_RUN_TIME_STATS 1 #define configUSE_STATS_FORMATTING_FUNCTIONS 1 #define configUSE_MUTEXES 1 #define traceTASK_SWITCHED_OUT() \ log_event( pxCurrentTCB, ulSwitchReason ); /* Co-routine definitions. */ #define configUSE_CO_ROUTINES 1 #define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) /* Set the following definitions to 1 to include the API function, or zero to exclude the API function. */ #define INCLUDE_vTaskPrioritySet 0 #define INCLUDE_uxTaskPriorityGet 0 #define INCLUDE_vTaskDelete 1 #define INCLUDE_vTaskCleanUpResources 0 #define INCLUDE_vTaskSuspend 0 #define INCLUDE_vTaskDelayUntil 1 #define INCLUDE_vTaskDelay 1 extern void vConfigureTimerForRunTimeStats(void); #define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vConfigureTimerForRunTimeStats() #define portGET_RUN_TIME_COUNTER_VALUE() TCNT0 #endif /* FREERTOS_CONFIG_H */