RT117x FreeRTOS Runtime Stats Configuration

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

RT117x FreeRTOS Runtime Stats Configuration

ソリューションへジャンプ
536件の閲覧回数
alonbl
Contributor III

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

 

タグ(3)
0 件の賞賛
1 解決策
506件の閲覧回数
alonbl
Contributor III

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,

元の投稿で解決策を見る

3 返答(返信)
507件の閲覧回数
alonbl
Contributor III

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,

512件の閲覧回数
alonbl
Contributor III

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.

 

0 件の賞賛
513件の閲覧回数
EdwinHz
NXP TechSupport
NXP TechSupport

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.

0 件の賞賛