Complete the code to enable an interrupt in the NVIC.
NVIC->ISER[0] = 1 << [1];
The NVIC Interrupt Set-Enable Register (ISER) uses the bit position to enable the corresponding interrupt number. Shifting 1 by 3 enables interrupt number 3.
Complete the code to set the priority of interrupt 7 in the NVIC.
NVIC->IP[[1]] = 0x40;
The NVIC Interrupt Priority Register (IP) array uses the interrupt number as the index. Setting IP[7] assigns priority to interrupt 7.
Fix the error in the code to clear a pending interrupt in the NVIC.
NVIC->ICPR[0] = 1 << [1];
The Interrupt Clear-Pending Register (ICPR) uses bits 0-31 for interrupts 0-31. Shifting 1 by 8 clears pending interrupt 8. Shifting by 32 is invalid as it exceeds 31.
Fill both blanks to configure the priority grouping in the NVIC.
NVIC_SetPriorityGrouping([1]); SCB->AIRCR = (0x5FA << 16) | ([2] << 8);
NVIC_SetPriorityGrouping configures how many bits are used for pre-emption priority and subpriority. The AIRCR register must be written with the key (0x5FA) and the priority grouping value shifted to bits 10:8. Using NVIC_PRIORITYGROUP_3 consistently sets this grouping.
Fill all three blanks to create a dictionary comprehension that maps interrupt numbers to their enabled status in NVIC.
enabled_interrupts = [1]: (NVIC->ISER[0] & (1 << [2])) != 0 for [3] in range(32)
This comprehension creates a dictionary where each key is an interrupt number (named 'interrupt') and the value is True if that interrupt is enabled in NVIC->ISER[0]. Using the same variable name 'interrupt' consistently is required for correct comprehension syntax.
