Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Paste this at the top of your main file
- #define EVER ;;
- #define RCC_PERHIPHBASE 0x40021000
- #define RCC_AHBENR (RCC_PERHIPHBASE + 0x14)
- #define GPIOB_PERIPHBASE 0x48000400
- #define GPIOB_MODER (GPIOB_PERIPHBASE + 0x00)
- #define GPIO_ODR (GPIOB_PERIPHBASE + 0x14)
- // Paste this in your main() function
- *((uint32_t *)RCC_AHBENR) |= 0b1000000000000000000; // Enable the GPIO Peripheral Clock (AHB Bus)
- *((uint32_t *)GPIOB_MODER) |= 0b01; // Set the pin mode of port B pin 1 to GENERAL PURPOSE OUTPUT MODE
- for (EVER) {
- *((uint32_t *)GPIO_ODR) ^= 0b1; // Toggle port B pin 1 by XOR-ing it
- // Pause for a bit by looping
- uint32_t i;
- for (i = 0; i < 100000; i++) {
- __asm("nop"); // This is the "correct" way to do nothing
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement