Moving code to ITC memory

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Moving code to ITC memory

跳至解决方案
2,779 次查看
bp1979
Senior Contributor I

Hi

I am trying to move code to ITC memory and verify that it indeed greatly improves performance.

I looked at the linker scripts generated by MCU Xpresso, and learned that the code decorated with "RamFunction" is moved to ram.

I added this code to a standard MCU Xpresso generated project for my RT 1020 EVK board

        GPIO1->DR ^= (1UL << 15);
        for (volatile int i=0; i<100000; i++)
        {
        	Nonsense();
        }
        GPIO1->DR ^= (1UL << 15);

 

And the Nonsense function here

 

void Nonsense()
{
    GPIO1->DR ^= (1UL << 23);
    for (volatile int i=0; i<1000; ++i)
    {
	__asm volatile ("nop");
    }
    GPIO1->DR ^= (1UL << 23);
}

 

I ran my baseline test, and in my logic analyzer I could see that every outer loop took roughly 1.8s.

Next I decorated both main and Nonsense() with the ramfunction macro as follows:

RAMFUNCTION_SECTION_CODE(void Nonsense())
{
    GPIO1->DR ^= (1UL << 23);
    for (volatile int i=0; i<1000; ++i)
    {
  	__asm volatile ("nop");
    }
    GPIO1->DR ^= (1UL << 23);
}

RAMFUNCTION_SECTION_CODE(int main(void))
{
    ...
    ...
}

 But the results are the same. It takes roughly 1.8seconds to complete the outer loop.

 

Am I completely missing the obvious here? Can somebody tell me how to get the performance boost I am trying to achieve by moving code to ITC? Or explain why this isn't showing any improvement at all?

0 项奖励
回复
1 解答
2,755 次查看
gusarambula
NXP TechSupport
NXP TechSupport

Hello Bp1979,

Have you followed the steps in section 17.13.5 of the MCUXpresso IDE User Guide?

https://www.nxp.com/docs/en/user-guide/MCUXpresso_IDE_User_Guide.pdf

As for performance depending on the kind of memory where the code resided, AN12437 (link below) and the following Knowledge Base document does cover the differences in speed between them.

https://community.nxp.com/t5/RT-4-Digit-10xx-11xx-12xx/iMXRTxxxx-Memory-Performance-ITCM-DTCM-L1-CAC...

https://www.nxp.com/docs/en/application-note/AN12437.pdf

I hope that this information helps.

Regards,
Gustavo

在原帖中查看解决方案

2 回复数
2,748 次查看
crist_xu
NXP Employee
NXP Employee

Hi,

     It seems that the reason is not where you place your code, for the code

is simple, I think the factor is the memory access caused by the for(volatile int i...)

 

Regards,

    Crist

0 项奖励
回复
2,756 次查看
gusarambula
NXP TechSupport
NXP TechSupport

Hello Bp1979,

Have you followed the steps in section 17.13.5 of the MCUXpresso IDE User Guide?

https://www.nxp.com/docs/en/user-guide/MCUXpresso_IDE_User_Guide.pdf

As for performance depending on the kind of memory where the code resided, AN12437 (link below) and the following Knowledge Base document does cover the differences in speed between them.

https://community.nxp.com/t5/RT-4-Digit-10xx-11xx-12xx/iMXRTxxxx-Memory-Performance-ITCM-DTCM-L1-CAC...

https://www.nxp.com/docs/en/application-note/AN12437.pdf

I hope that this information helps.

Regards,
Gustavo