/* p6_4.c Toggle the LED using the SysTick interrupt * * This program sets up the SysTick to interrupt at 1 Hz. * The system clock is running at 8 MHz. * 1 sec/1 us = 8,000,000-1 for RELOAD register. * In the interrupt handler, the LED is toggled. * * This program was tested with Keil uVision v5.24a with DFP v2.11.0 */ #include "stm32F0xx.h" int main(void) { __disable_irq(); /* global disable IRQs */ RCC->AHBENR |= 0x00020000; /* enable GPIOA clock */ GPIOA->MODER &= ~0x00000C00; /* clear pin mode */ GPIOA->MODER |= 0x00000400; /* set pin to output mode */ /* Configure SysTick */ SysTick->LOAD = 8000000 - 1; /* reload with number of clocks per second */ SysTick->VAL = 0; SysTick->CTRL = 7; /* enable SysTick interrupt, use system clock */ __enable_irq(); NVIC_SetPriority(SysTick_IRQn, 2); while (1) { }} void SysTick_Handler(void) { GPIOA->ODR ^= 0x00000020; /* turn on LED */ }