px-lib  0.9.2
Cross-platform embedded library and documentation for 8/16/32-bit microcontrollers

How to implement a simple interrupt handler.


A timer is configured to generate an interrupt every 250 ms. The LED output pin is toggled every 250 ms in the timer interrupt.

A macro sei() is called to enable interrupts globally. It sets bit 7 (I) of the SREG register. cli() can be called to disable all interrupts.

Refer to Table 12-6 "Reset and Interrupt Vectors in ATmega328 and ATmega328P" on page 65 of the ATmega328p datasheet to view the full list of interrupt vectors. Assuming Atmel Studio 7 is installed in it's default location, the interrupt vector names are defined in:

C:\Program Files (x86)\Atmel\Studio\7.0\toolchain\avr8\avr8-gnu-toolchain\avr\include\avr\iom328p.h