Interrupts
The Nested Vectored Interrupt Controller (NVIC) is an integral part of any Cortex-M microcontroller. On the LPC18xx, the NVIC supports 53 vectored interrupts.
Each of the LPC43xx cores has its own nested verctor interrupt controller. The ARM Cortex-M4 core supports 53 vectored interrupts. The NVIC in ARM Cortex-M0 core supports 32 interrupts.
Most of the peripheral interrupts are shared between the Cortex-M0 and Cortex-M4 NVICs. You can handle peripheral interupts with Cortex-M0 core and use Cortex-M4 core for complex calculations (like digital signal processing).
The LPC43xx interrupts are also used for inter-process communication. We will use these interrupts later in the tutorial, when we discuss the communication between Cortex-M0 and Cortex-M4 cores.
The CMSIS library contains the assembly language source file startup_LPC43xx.s
that declare the interrupt vector table (it is almost identical to the startup_LPC18xx.s file for LPC43xx microcontrollers). You can find it at the lpc43xx\Core\Device\NXP\LPC43xx\Source\Templates\IAR
folder.
Let's add the startup_LPC43xx.s
file to our project using menu [Project | Add Files...]
. In the Add Files dialog box navigate to the lpc43xx\Core\Device\NXP\LPC43xx\Source\Templates\IAR
folder and open the startup_LPC43xx.s
file:
The first ten interrupts are fixed by ARM. You will find the same interrupts in any other Cortex-M microcontroller. We will implicitly use the first two elements of the interrupt table array:
__vector_table DCD sfe(CSTACK) DCD Reset_Handler
The first element is initialized with the initial stack pointer - CSTACK. It is defined in the linker script file.
The second element contains the address of the reset handler, which is implemented in the same startup_LPC43xx.s
file. It simply calls the __iar_program_start()
function, which initializes the device RAM and calls our main()
function.
Reset_Handler LDR R0, =__iar_program_start BX R0
All interrupt handlers in startup_LPC43xx.s
file are defined with the PUBWEAK directive:
PUBWEAK GPIO0_IRQHandler SECTION .text:CODE:REORDER(1) GPIO0_IRQHandler B GPIO0_IRQHandler
The PUBWEAK directive allows the same symbol to be defined in more than one module. We will use this feature to override the GPIO interrupt.