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
解決済! 解決策の投稿を見る。
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:
In the case of S12Z, you may choose between several types of periodic interrupts:
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
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:
In the case of S12Z, you may choose between several types of periodic interrupts:
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