/* p6_5.c Toggle the LED0 using the SysTick interrupt * * This program sets up the SysTick to interrupt at 1 Hz. * The system clock is running at 1 MHz. * 1 sec/1 us = 1,000,000 for RELOAD register. * In the interrupt handler, the LED0 is toggled. * * Tested with Atmel Studio 7 v7.0.1006 and Keil MDK-ARM v5.21a */ #include "samd21.h" int main(void) { __disable_irq(); REG_PORT_DIRSET1 = 0x40000000; /* make PB30 output for LED */ /* Configure SysTick */ SysTick->LOAD = 1000000-1; /* reload with number of clocks per second */ SysTick->VAL = 1000000-1; SysTick->CTRL = 7; /* enable SysTick interrupt, use system clock */ __enable_irq(); while (1) { } } void SysTick_Handler(void) { REG_PORT_OUTTGL1 = 0x40000000; /* toggle LED0 */ }