Moving code to ITC memory

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

Moving code to ITC memory

ソリューションへジャンプ
2,816件の閲覧回数
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,792件の閲覧回数
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,785件の閲覧回数
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,793件の閲覧回数
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