SLAU847D October 2022 – May 2024 MSPM0L1105 , MSPM0L1106 , MSPM0L1227 , MSPM0L1228 , MSPM0L1228-Q1 , MSPM0L1303 , MSPM0L1304 , MSPM0L1304-Q1 , MSPM0L1305 , MSPM0L1305-Q1 , MSPM0L1306 , MSPM0L1306-Q1 , MSPM0L1343 , MSPM0L1344 , MSPM0L1345 , MSPM0L1346 , MSPM0L2227 , MSPM0L2228 , MSPM0L2228-Q1
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();
}
}