Hi Anwar,
Q1)
When CPU jumps into interrupt routine, it sets I-bit in CPU CCW register. This way it blocks other I-bit maskable interrupts. The I-bit is cleared during ISR leaving (RTI instruction). So, the calling asm STOP instruction inside ISR typically causes partially brick of MCU (wake-up only by non I-bit maskable interrupts). When you clear I-bit manually inside ISR prior calling asm STOP instruction, the MCU may be wake-up only be non I-bit maskable interrupts (like XIRQ) or by I-bit maskable interrupts with higher priority than currently executed ISR.
So, you may call asm STOP instruction anywhere in your code, but you must consider the available wake-up sources. Typically, we do not call asm STOP instruction inside any ISR, but somewhere in the main loop – that all interrupts/wake-up sources are available.
Driving wake-up capability by interrupt priority is not a practical solution. You may simply disable/enable appropriate interrupts prior asm STOP instruction. The priority settings should be used for priority configuration during run mode.
Q2)
Yes, there is up to 128 interrupt vectors. For the saving number of registers, the access to priority level is managed by paging mechanism. INT_CFADDR is a page and INT_CFDATA0–7 registers may be used for priority level configuration of 8 appropriate interrupt vectors.
You may configure INT_CFDATAx values despite on fact whether appropriate interrupt is enabled or disabled.
Note: Priority 0 effectively mean disabled interrupt.
Note: The RTI may wake-up MCU only from Pseudo Stop Mode (External oscillator (XOSCLCP) continues to run). TIMx module cannot wake-up MCU from any of stop modes.
For example:
/*Interrupt Request Configuration Address Register*/
INT_CFADDR = 0x70;
INT_CFDATA3_PRIOLVL = 0x01; /*Priority level of TIM0_C0I*/
INT_CFDATA4_PRIOLVL = 0x02; /*Priority level of Real Time Interrupt*/
INT_CFADDR = 0x50;
INT_CFDATA5_PRIOLVL = 0x04; /*Priority level of CAN receive*/
INT_CFDATA7_PRIOLVL = 0x04; /*Priority level of CAN wake-up*/
INT_CFADDR = 0x40;
INT_CFDATA3_PRIOLVL = 0x05; /*Priority level of port P ISR*/
INT_CFDATA1_PRIOLVL = 0x06; /*Priority level of LVI*/
INT_CFDATA0_PRIOLVL = 0x07; /*Priority level of API*/
Note: when you divide vector address in hex format by 4, you will get hex number where lower 3 bits [0..2] refers to selected register INT_CFDATAx and upper 4 bits [3..6] refers to page register INT_CFADDR value.
If you set for example INT_CFADDR = 0x40, you may configure priority for the Interrupt vector addresses (Vector base + 0x100, 0x104, 0x108, 0x10C, 0x110, 0x114, 0x118, 0x11C)
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!
-----------------------------------------------------------------------------------------------------------------------