i.MXRT1160 performance issue

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

i.MXRT1160 performance issue

Jump to solution
579 Views
adam_smith
Contributor II

Hello everyone,

I have a MIMXRT1160-EVK and I have created this simple project:

 

gpt_config_t gptConfig;

memset(&gptConfig, 0, sizeof(gptConfig));

gptConfig.clockSource = kGPT_ClockSource_Periph;
gptConfig.divider = 1U;
gptConfig.enableRunInStop = true;
gptConfig.enableRunInWait = true;
gptConfig.enableRunInDoze = false;
gptConfig.enableRunInDbg = false;
gptConfig.enableFreeRun = true;
gptConfig.enableMode = false;

GPT_Init(GPT2, &gptConfig);

GPT_StartTimer(GPT2);

 

uint32_t timer_value1, timer_value2;

timer_value1 = GPT_GetCurrentTimerCount(GPT2);

timer_value2 = GPT_GetCurrentTimerCount(GPT2);

uint32_t diff = timer_value2 - timer_value1;

PRINTF("%d", diff);

 

This is a simple project built on top of Cortex-M7 running at a maximum speed of 600 MHz. Code and data are executed from ITCM and DTCM respectively.

The GPT2 clock source has a default value of 24 MHz.

I am reading a value of 6 as output from the printf function.

So, if the code is to run at 600 MHz, this simple example of consecutively reading the timer tick values ​​should report almost a difference of 0.

The value 6 corresponds to 6 * (600/24) = 150 CPU cycles.

Why am I reading a value so slow?

Note: The project was created with MCUXpresso and based on the GPT example without using interrupts or changing the clock settings, just using the default values.

Any ideas?

0 Kudos
1 Solution
529 Views
diego_charles
NXP TechSupport
NXP TechSupport

Hi @adam_smith 

Very interesting findings!

Processor is actually running at 600 MHz as you mention. I obtained the same results than you by even  executing from external flash. 

If we apply optimization to your code, we may reduce the time difference to 5 units, but by inspecting the dissasembly code, there is not too much left to optimize. If we change the clock source in the code of the GPT to  kGPT_ClockSource_LowFreq  we can get a difference of zero.

To verify that the kGPT_ClockSource_Periph is actually set to 24 Mhz I recommend you to use an external clock frequency of 24 MHz for the GPT, and run the code again. So we can have elements discard that this timer is not being clocked with an even higher frequency. 

Btw, when reading memory mapped registers, like the CNT register of the GPT, we may get slower performance, as the external peripherals are connected to an internal cross bar switch, not accesible directly to the processor. 

Diego

 

View solution in original post

0 Kudos
2 Replies
530 Views
diego_charles
NXP TechSupport
NXP TechSupport

Hi @adam_smith 

Very interesting findings!

Processor is actually running at 600 MHz as you mention. I obtained the same results than you by even  executing from external flash. 

If we apply optimization to your code, we may reduce the time difference to 5 units, but by inspecting the dissasembly code, there is not too much left to optimize. If we change the clock source in the code of the GPT to  kGPT_ClockSource_LowFreq  we can get a difference of zero.

To verify that the kGPT_ClockSource_Periph is actually set to 24 Mhz I recommend you to use an external clock frequency of 24 MHz for the GPT, and run the code again. So we can have elements discard that this timer is not being clocked with an even higher frequency. 

Btw, when reading memory mapped registers, like the CNT register of the GPT, we may get slower performance, as the external peripherals are connected to an internal cross bar switch, not accesible directly to the processor. 

Diego

 

0 Kudos
512 Views
adam_smith
Contributor II
Hi @diego_charles
I thought the peripheral registers were mapped to some fast memory region, but as you mentioned, there is some delay due to the internal crossbar.

I changed my application to use the DWT unit instead of a generic timer to count execution cycles and now I read 6 cycles at 600 MHz. That makes sense, and I will use this unit to implement my future profiling routines.

Thank you