#include #define RCC_AHB1ENR_BIT_GPIODEN *(volatile uint32_t*)(0x42000000 + 0x00023830 * 32 + 3 * 4) #define GPIOD_BASE 0x40020C00 #define GPIOD_MODER *(volatile uint32_t*)(GPIOD_BASE + 0x00) #define GPIOD_ODR *(volatile uint32_t*)(GPIOD_BASE + 0x14) #define STK_CTRL *(volatile uint32_t*)(0xE000E010) #define STK_LOAD *(volatile uint32_t*)(0xE000E014) int main(void) { // GPIO Port D Clock Enable RCC_AHB1ENR_BIT_GPIODEN = 1; // GPIO Port D Pin 15 down to 12 Push/Pull Output GPIOD_MODER = 0x55000000; // Set green and red LEDs GPIOD_ODR = 0x5000; // SysTick enable with clk source to AHB/8 // (AHB is by default HSI; 16 MHz/8) STK_CTRL = 1; STK_LOAD = 1000000; // 16 MHz / 8 / 2 Hz // Do forever: while (1) { // Wait a moment while ((STK_CTRL & (1 << 16)) == 0); // Flip all LEDs GPIOD_ODR ^= 0xF000; } }