Advertisement
dtung

GPIO speed

Sep 25th, 2020
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include "stm32f10x.h"
  2.  
  3. void gpio_init(void);
  4.  
  5. void gpio_init() {
  6. // enable PORTC GPIO13 to output push-pull with max_speed 50MHz
  7. RCC->APB2ENR |= RCC_APB2ENR_IOPCEN;
  8. GPIOC->CRH &= ~(GPIO_CRH_CNF13|GPIO_CRH_MODE13);
  9. GPIOC->CRH |= GPIO_CRH_MODE13;
  10. }
  11.  
  12. int main() {
  13. gpio_init();
  14.  
  15. for (;;) {
  16. GPIOC->ODR = 0x2000;
  17. GPIOC->ODR = 0x0000;
  18. GPIOC->ODR = 0x2000;
  19. GPIOC->ODR = 0x0000;
  20. GPIOC->ODR = 0x2000;
  21. GPIOC->ODR = 0x0000;
  22. GPIOC->ODR = 0x2000;
  23. GPIOC->ODR = 0x0000;
  24. GPIOC->ODR = 0x2000;
  25. GPIOC->ODR = 0x0000;
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement