there are 32 interrupts in HCS08 family, and HCS08 MCUs do not support nesting interrupts. Can I use more than 1 interrutps? in my application, 2 ISRs ared need as following
void interrupt 30 ACMP_ISR(void) /* low priority */
{
/* code here */
}
void interrutp 25 RTC_ISR(void) /* high priority */
{
/* code here */
}
if RTC_ISR() is being executed, at the same time, ACMP interrupt is generated, when program exits from RTC_ISR() , the ACMP_ISR() is lost or not? since the priority of RTC interrupt is high than ACMP interrupt.
Solved! Go to Solution.
Hello,
You may have as many different interrupts enabled as you require for an application. When an interrupt trigger occurs, a flag will be set to indicate an interrupt event. If no other interrupt is currently being serviced, the ISR code for that interrupt will be immediately entered.
However, if another interrupt is already being serviced, the servicing of the new interrupt will be delayed until the other ISR code exits. If more than one other interrupt is queued, the order of servicing the queued interrupts will take into account the interrupt priorities.
No interrupt event will be lost since the interrupt flag will remain set until servicing takes place. The sequential servicing of interrupts is the reason that ISR code should be as short as possible.
For your application, you will need to evaluate whether the execution time of the ACMP ISR code represents an allowable maximum delay to the execution of the RTC ISR code.
Nested interrupts are possible, but should only be considered as a last resort, due to increased code overheads and stack requirements. For your case, the ACMP ISR code would need disable further ACMP interrupts from occurring, prior to globally re-enabling interrupts. Just prior to exiting the ACMP ISR, interrupts would need to be again globally disabled, and the ACMP interrupt re-enabled.
If you had more than one lower priority interrupt, all of these would need to be temporarily disabled, to allow a single high priority interrupt only to be nested.
Should your ACMP code be too lengthy, for whatever reason, and provided your RTC code is very short, there might be another approach. This is to poll the RTC flag from within the ACMP ISR, and execute the RTC code from there. This could be done at more than one place within the code sequence. Since the RTC flag would be cleared by the RTC code, the RTC interrupt would not occur when the ACMP ISR exited.
Regards,
Mac
Hello,
You may have as many different interrupts enabled as you require for an application. When an interrupt trigger occurs, a flag will be set to indicate an interrupt event. If no other interrupt is currently being serviced, the ISR code for that interrupt will be immediately entered.
However, if another interrupt is already being serviced, the servicing of the new interrupt will be delayed until the other ISR code exits. If more than one other interrupt is queued, the order of servicing the queued interrupts will take into account the interrupt priorities.
No interrupt event will be lost since the interrupt flag will remain set until servicing takes place. The sequential servicing of interrupts is the reason that ISR code should be as short as possible.
For your application, you will need to evaluate whether the execution time of the ACMP ISR code represents an allowable maximum delay to the execution of the RTC ISR code.
Nested interrupts are possible, but should only be considered as a last resort, due to increased code overheads and stack requirements. For your case, the ACMP ISR code would need disable further ACMP interrupts from occurring, prior to globally re-enabling interrupts. Just prior to exiting the ACMP ISR, interrupts would need to be again globally disabled, and the ACMP interrupt re-enabled.
If you had more than one lower priority interrupt, all of these would need to be temporarily disabled, to allow a single high priority interrupt only to be nested.
Should your ACMP code be too lengthy, for whatever reason, and provided your RTC code is very short, there might be another approach. This is to poll the RTC flag from within the ACMP ISR, and execute the RTC code from there. This could be done at more than one place within the code sequence. Since the RTC flag would be cleared by the RTC code, the RTC interrupt would not occur when the ACMP ISR exited.
Regards,
Mac
thanks bigmac,
now, i understand the meaning of nesting interupt, which means that if a high interrutp occurs during progress of the service of a low interrupt , the high interrupt can take CPU from the low interrupt immediately, no waiting.
no interrupt should lost even if the CUP do not support the nesting interrupt scheduling(preemptive scheduling), it only delay the service time.