SLAU846B June 2023 – November 2024 MSPM0G1105 , MSPM0G1106 , MSPM0G1107 , MSPM0G1505 , MSPM0G1506 , MSPM0G1507 , MSPM0G1519 , MSPM0G3105 , MSPM0G3105-Q1 , MSPM0G3106 , MSPM0G3106-Q1 , MSPM0G3107 , MSPM0G3107-Q1 , MSPM0G3505 , MSPM0G3505-Q1 , MSPM0G3506 , MSPM0G3506-Q1 , MSPM0G3507 , MSPM0G3507-Q1 , MSPM0G3519
In the case of an event which generates a CPU interrupt, application software can determine which peripheral interrupt triggered the generation of the event by either reading the IIDX register or by reading the MIS and writing the ICLR registers.
Application software can read the IIDX register in CPU_INT group to determine and clear the highest priority pending interrupt. A read to IIDX will return an index corresponding to the highest priority interrupt which was both set and unmasked. The read action will also simultaneously clear the RIS and MIS bits corresponding to the highest priority interrupt whose index was returned by the read. The read value from the IIDX register can then be used in a case statement, as shown below.
void ISR_IIDX(void)
{
switch(IIDX)
{
case 0: // no IRQ pending
break;
case 1: // IRQ[0]
do_irq0();
break;
case 2: // IRQ[1]
do_irq1();
break;
default: // out of range
illegal();
}
}
Alternatively, application software can read the MIS register to determine which bits are set, followed by using the ICLR register to clear the pending interrupt status bits.
void ISR(void)
{
uint32_t pending = MIS;
ICLR = pending; // clear pending IRQ
if (pending & 0x01) // IRQ[0]
{
do_irq0();
}
if (pending & 0x02) // IRQ[1]
{
do_irq1();
}
}