Advertisement
Guest User

Untitled

a guest
Aug 1st, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. // Paste this at the top of your main file
  2. #define EVER ;;
  3.  
  4. #define RCC_PERHIPHBASE 0x40021000
  5. #define RCC_AHBENR (RCC_PERHIPHBASE + 0x14)
  6.  
  7. #define GPIOB_PERIPHBASE 0x48000400
  8. #define GPIOB_MODER (GPIOB_PERIPHBASE + 0x00)
  9. #define GPIO_ODR (GPIOB_PERIPHBASE + 0x14)
  10.  
  11. // Paste this in your main() function
  12. *((uint32_t *)RCC_AHBENR) |= 0b1000000000000000000; // Enable the GPIO Peripheral Clock (AHB Bus)
  13. *((uint32_t *)GPIOB_MODER) |= 0b01; // Set the pin mode of port B pin 1 to GENERAL PURPOSE OUTPUT MODE
  14.  
  15. for (EVER) {
  16. *((uint32_t *)GPIO_ODR) ^= 0b1; // Toggle port B pin 1 by XOR-ing it
  17.  
  18. // Pause for a bit by looping
  19. uint32_t i;
  20. for (i = 0; i < 100000; i++) {
  21. __asm("nop"); // This is the "correct" way to do nothing
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement