Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #include "stm32f10x.h"
  2. #include "stm32f10x_exti.h"
  3. #include "stm32f10x_gpio.h"
  4. #include "stm32f10x_rcc.h"
  5. #include "misc.h"
  6.  
  7. #define przesuniete 1<<5;
  8.  
  9. GPIO_InitTypeDef GPIO_InitStruct;
  10.  
  11. int przerwanie = 0;
  12.  
  13. void SysTick_Handler() {
  14.  
  15. przerwanie++;
  16. //gdy wystąpi 1000 z kolei przerwanie SysTick (minie 1 sekunda)
  17. if (przerwanie == 1000) {
  18. //resetuję stan licznika przerwań
  19. przerwanie = 0;
  20.  
  21. GPIOA->ODR ^= przesuniete;
  22. }
  23. }
  24.  
  25. void konfiguracjaDiody(void) {
  26.  
  27. RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
  28.  
  29. GPIO_StructInit(&GPIO_InitStruct);
  30.  
  31. GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;
  32. //konfiguracja prędkości (takowania) portu na szybkie
  33. GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
  34.  
  35. GPIO_InitStruct.GPIO_Pin = GPIO_Pin_5;
  36.  
  37. GPIO_Init(GPIOA, &GPIO_InitStruct);
  38. }
  39.  
  40.  
  41. int main(void) {
  42. //konfiguracja SysTick - przerwanie, co 1ms, gdzie 72000000 to taktowanie proc.
  43. SysTick_Config(72000000 / 1000);
  44.  
  45. konfiguracjaDiody();
  46. while (1) {
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement