Moving ISR to SRAM

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

Moving ISR to SRAM

跳至解决方案
2,414 次查看
manishsangram
Contributor IV


Hi

We are using S12ZVMC128. We would like to move some of the ISRs to SRAM for faster execution. What is the easiest way to declare this to the compiler? How much performance improvement can we expect in code execution speed between SRAM and flash? We are running the core at 50Mhz/100Mhz speed. Would the execution speed be about 2x in SRAM compared to Flash?

标签 (1)
标记 (2)
1 解答
2,224 次查看
RadekS
NXP Employee
NXP Employee

Hi Manish,

The simplest way is just let it know to the linker. For example:

#pragma CODE_SEG DEFAULT_RAM

void PFLASH_Send_Command(void)

{

  DisableInterrupts;

  FSTAT_CCIF = 1;          //launch command

  while(FSTAT_CCIF == 0){}; //wait for done

  EnableInterrupts;

}

#pragma CODE_SEG DEFAULT

The Starts12z.c code will automatically load your code into RAM.

Note: The DEFAULT_RAM could be used only for S12Z and CW10. The S12(X) linker in CW 5.1(or 5.2; Classic IDE) needs use user segment instead of the default (like DEFAULT_RAM).

You are right that speed of Flash reading might limit code execution, but I will not expect that the speed increasing ratio will be directly 2. It is mainly because not all instructions have shortest execution time and because the flash is read few bus cycles prior instruction execution. The ratio will depend on executed instructions. However, I never measure it.

I hope it helps you.

Have a great day,
Radek

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

在原帖中查看解决方案

1 回复
2,225 次查看
RadekS
NXP Employee
NXP Employee

Hi Manish,

The simplest way is just let it know to the linker. For example:

#pragma CODE_SEG DEFAULT_RAM

void PFLASH_Send_Command(void)

{

  DisableInterrupts;

  FSTAT_CCIF = 1;          //launch command

  while(FSTAT_CCIF == 0){}; //wait for done

  EnableInterrupts;

}

#pragma CODE_SEG DEFAULT

The Starts12z.c code will automatically load your code into RAM.

Note: The DEFAULT_RAM could be used only for S12Z and CW10. The S12(X) linker in CW 5.1(or 5.2; Classic IDE) needs use user segment instead of the default (like DEFAULT_RAM).

You are right that speed of Flash reading might limit code execution, but I will not expect that the speed increasing ratio will be directly 2. It is mainly because not all instructions have shortest execution time and because the flash is read few bus cycles prior instruction execution. The ratio will depend on executed instructions. However, I never measure it.

I hope it helps you.

Have a great day,
Radek

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------