Interrupts

Interrupts, when they occur execute code found in a memory location (which is reserved for that interrupt), save the state of the MCU, execute the code, then restore the MCU state. There are many other optional factors affecting interrupts, such as priority, triggers and so on.

Mecrisp-Stellaris uses the “tick” (‘) Word to obtain the memory location of the Word to be executed, and supplies this to the interrupt handler code.

The following code snippet, taken from Blinky-5, uses the Systick Interrupt to execute the Word * toggle-led* everytime the Systick Interrupt occurs, which is every 1 second in this example :-

' toggle-led irq-systick !
  8000000  STK_RVR !            \ Configure the Systick interval counter. The clock is 8MHz, so this will interrupt every second
  7 STK_CSR !                   \ Enable the Systick interrupt

Methods

1) obtain the memory address location of the Word “toggle-led” with the following code :-

' toggle-led
  1. save this memory address to the irq-systick interrupt vector address
irq-systick !
  1. Configure and enable the interrupt.
8000000  STK_RVR !              \ Configure the Systick interval counter. The clock is 8MHz, so this will interrupt every second
7 STK_CSR !                     \ Enable the Systick interrupt

Cortex M0 Interrupt Flowchart

_images/int.png

Table Of Contents

Previous topic

Loadmeter

Next topic

Alternate Functions

This Page