Moving code to ITC memory

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

Moving code to ITC memory

Jump to solution
1,860 Views
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 Kudos
Reply
1 Solution
1,836 Views
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

View solution in original post

2 Replies
1,829 Views
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 Kudos
Reply
1,837 Views
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