Hello,
I would like to ask if anyone had setup the FreeRTOS on the RT117x so that the runtime statistics will be functional.
Reference[1], need something like:
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vConfigureTimerForRunTimeStats() #define portGET_RUN_TIME_COUNTER_VALUE() T0TC
The default NXP port does not provide these settings.
It would be nice if the clock will be 1MHz as I will be able to use it for other tasks as well.
Thanks,
Alon
[1] https://www.freertos.org/rtos-run-time-stats.html
已解决! 转到解答。
Hi,
It was simpler than I though... still learning this platform...
To anyone that is interested, the following works.
1. Setup GPT module from SDK + GPT instance in peripherals.
The following setup will create 1MHz which is started at system boot.
instance:
- name: 'GPT1'
- type: 'gpt'
- mode: 'general'
- functional_group: 'BOARD_InitPeripherals'
- peripheral: 'GPT1'
- config_sets:
- fsl_gpt:
- gpt_config:
- clockSource: 'kGPT_ClockSource_Periph'
- clockSourceFreq: 'ClocksTool_DefaultInit'
- oscDivider: '1'
- divider: '24'
- enableFreeRun: 'true'
- enableRunInWait: 'false'
- enableRunInStop: 'false'
- enableRunInDoze: 'false'
- enableRunInDbg: 'false'
- enableMode: 'true'
- isInterruptEnabled: 'false'
- EnableTimerInInit: 'true'
2. Configure the following in FreeRTOSConfig.h:
#include "fsl_gpt.h"
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
#define portGET_RUN_TIME_COUNTER_VALUE() GPT_GetCurrentTimerCount(GPT1)
* I could not include peripherals.h due to some conflicts in its definition with other modules, so I used symbols GPT1 directly instead of GPT1_PERIPHERAL.
And that's It.
Of course this can be extended/enhanced, but is trivial and takes no CPU to count.
Regards,
Hi,
It was simpler than I though... still learning this platform...
To anyone that is interested, the following works.
1. Setup GPT module from SDK + GPT instance in peripherals.
The following setup will create 1MHz which is started at system boot.
instance:
- name: 'GPT1'
- type: 'gpt'
- mode: 'general'
- functional_group: 'BOARD_InitPeripherals'
- peripheral: 'GPT1'
- config_sets:
- fsl_gpt:
- gpt_config:
- clockSource: 'kGPT_ClockSource_Periph'
- clockSourceFreq: 'ClocksTool_DefaultInit'
- oscDivider: '1'
- divider: '24'
- enableFreeRun: 'true'
- enableRunInWait: 'false'
- enableRunInStop: 'false'
- enableRunInDoze: 'false'
- enableRunInDbg: 'false'
- enableMode: 'true'
- isInterruptEnabled: 'false'
- EnableTimerInInit: 'true'
2. Configure the following in FreeRTOSConfig.h:
#include "fsl_gpt.h"
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
#define portGET_RUN_TIME_COUNTER_VALUE() GPT_GetCurrentTimerCount(GPT1)
* I could not include peripherals.h due to some conflicts in its definition with other modules, so I used symbols GPT1 directly instead of GPT1_PERIPHERAL.
And that's It.
Of course this can be extended/enhanced, but is trivial and takes no CPU to count.
Regards,
Hello @EdwinHz,
Thank you for the reference.
This implementation is using interrupts to increment the counter by software.
The example for LPC17xx that presented at [1] suggests that NXP CPU family may have hardware based counters which will be much more efficient.
Do you know any similar method to implement this kind of a solution in RT117x?
Thanks,
[1] https://www.freertos.org/rtos-run-time-stats.html
I wounder if there is some other method that increments the counter in hardware.
Hi @alonbl,
Please look into the following blog post, as it goes into a lot of detail about how to properly configure the runtime statistics using FreeRTOS. It has been specifically implemented for the RT1064, but the same process and setup applies for the RT1170 as well:
https://mcuoneclipse.com/2020/04/15/freertos-task-runtime-statistics-for-nxp-i-mx-rt1064/
BR,
Edwin.