Bootloader interrupt

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
1,537件の閲覧回数
AjRj14
Contributor III

Hi ,

I am following the application note : "Simple serial bootloader for s12z" for my bootloader project.

But my bootloader requires TIMER interrupt.

Can the bootloader also have interrupts? If yes, could you please tell me what to do.

 

Thanks in Advance

0 件の賞賛
1 解決策
1,515件の閲覧回数
RadekS
NXP Employee
NXP Employee

Hello AjRj14,

Yes, the bootloader may use interrupts. The bootloader owns and protects the default vector table area in the flash.

In fact, the bootloader already uses for example SCI module in interrupt mode for serial communication.

 

What you need to do:

  • You need to create and call timer init function
  • You need to create interrupt service routine (ISR) for this timer
  • (You need to check whether the bootloader with these modifications still may fit into the allocated Flash/RAM area. If not, give more space for bootloader (check map file – potentially edit prm linker file).)

 

In the case of S12Z, you may choose between several types of periodic interrupts:

  • Real time interrupt (RTI),
  • Autonomous periodic interrupt (API) or
  • Timer (TIM) Output Compare mode.

The code for it is pretty simple in all three cases. It depends on your preference. Few write into registers and flag clearing in an interrupt routine. Only in the case of TIM, you need to also additionally update the TCx value in each ISR.

For example API:

//==============================================================================

// API_Init

//==============================================================================

void API_Init(void)

  CPMUAPIR = 30D3;       //1ms interval @25Mhz bus clock 

  CPMUAPICTL = 0x89;     //bus clk is source of clock, API enable,

                         //interrupt disable, clear flag if set

  CPMUAPICTL_APIFE = 1;  //API enable

}

 

 

//==============================================================================// API_ISR//==============================================================================

interrupt VectorNumber_Vapi void API_ISR(void)

{    

//your code 

CPMUAPICTL = CPMUAPICTL_APIF_MASK;   //clear APIF flag

Note: the vector number (e.g. VectorNumber_Vapi) may by found in your derivative header file - right on begining.
Note: If you use bootloader in self-rewritable mode, you need to relocate interrupt routine into RAM and set appropriate interrupt vector in RAM - follow the SCI example in AN12086 code.

 

I hope it helps you. 

 

Best regards

RadekS

元の投稿で解決策を見る

0 件の賞賛
1 返信
1,516件の閲覧回数
RadekS
NXP Employee
NXP Employee

Hello AjRj14,

Yes, the bootloader may use interrupts. The bootloader owns and protects the default vector table area in the flash.

In fact, the bootloader already uses for example SCI module in interrupt mode for serial communication.

 

What you need to do:

  • You need to create and call timer init function
  • You need to create interrupt service routine (ISR) for this timer
  • (You need to check whether the bootloader with these modifications still may fit into the allocated Flash/RAM area. If not, give more space for bootloader (check map file – potentially edit prm linker file).)

 

In the case of S12Z, you may choose between several types of periodic interrupts:

  • Real time interrupt (RTI),
  • Autonomous periodic interrupt (API) or
  • Timer (TIM) Output Compare mode.

The code for it is pretty simple in all three cases. It depends on your preference. Few write into registers and flag clearing in an interrupt routine. Only in the case of TIM, you need to also additionally update the TCx value in each ISR.

For example API:

//==============================================================================

// API_Init

//==============================================================================

void API_Init(void)

  CPMUAPIR = 30D3;       //1ms interval @25Mhz bus clock 

  CPMUAPICTL = 0x89;     //bus clk is source of clock, API enable,

                         //interrupt disable, clear flag if set

  CPMUAPICTL_APIFE = 1;  //API enable

}

 

 

//==============================================================================// API_ISR//==============================================================================

interrupt VectorNumber_Vapi void API_ISR(void)

{    

//your code 

CPMUAPICTL = CPMUAPICTL_APIF_MASK;   //clear APIF flag

Note: the vector number (e.g. VectorNumber_Vapi) may by found in your derivative header file - right on begining.
Note: If you use bootloader in self-rewritable mode, you need to relocate interrupt routine into RAM and set appropriate interrupt vector in RAM - follow the SCI example in AN12086 code.

 

I hope it helps you. 

 

Best regards

RadekS

0 件の賞賛