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

Interrupt and Exception Vectors

Position Priority Type of Priority Acronym Description
         

STM32F0 Discovery Board Interrupt Example Program

Exercise Interrupt program to light a STM32F0 Discovery LED when the USER pushbutton is pressed

  • Stand alone, no other files needed, upload and run
  • Prints the status when the USER pushbutton is pressed, i.e
USER Push Button Interrupt detected EXTI_PR = 00000001
cleared  EXTI_PR-0
EXTI_PR = 00000000

STM32F0 Discovery Board Interrupt Example

Table Of Contents

Previous topic

Loadmeter

Next topic

Alternate Functions

This Page