Your SlideShare is downloading. ×
Stm32 discovery ile ilk_adimlar
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Stm32 discovery ile ilk_adimlar

2,556

Published on

STM32 Discovery kartı'na giriş

STM32 Discovery kartı'na giriş

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,556
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
292
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. STM32 Discovery Kartı ile ilk adımlar – Co kun TA DEM R http://www.coskuntasdemir.net -1-
  • 2. STM32 Discovery Kartı ile ilk adımlar – Co kun TA DEM R http://www.coskuntasdemir.net -2-
  • 3. STM32 Discovery Kartı ile ilk adımlar – Co kun TA DEM R http://www.coskuntasdemir.net -3- • 56 3 L7 " A • E F /# J + F /# 65 • E # 53 • 5 E # 53 • G • M)+ ) 3+ < 56 # # • @E )- • 363 & ! • N/ 5 • O # , C O D P 5( #
  • 4. STM32 Discovery Kartı ile ilk adımlar – Co kun TA DEM R http://www.coskuntasdemir.net -4-
  • 5. STM32 Discovery Kartı ile ilk adımlar – Co kun TA DEM R http://www.coskuntasdemir.net -5-RCC->APB2ENR |= 1 << 4
  • 6. STM32 Discovery Kartı ile ilk adımlar – Co kun TA DEM R http://www.coskuntasdemir.net -6-
  • 7. STM32 Discovery Kartı ile ilk adımlar – Co kun TA DEM R http://www.coskuntasdemir.net -7-
  • 8. STM32 Discovery Kartı ile ilk adımlar – Co kun TA DEM R http://www.coskuntasdemir.net -8-
  • 9. STM32 Discovery Kartı ile ilk adımlar – Co kun TA DEM R http://www.coskuntasdemir.net -9-1 /*----------------------------------------------------------------------------2 MAIN function3 *----------------------------------------------------------------------------*/4 int main (void) {56 LED_Config();7 BTN_Config();89 SysTick_Config(SystemCoreClock / 100); /* Setup SysTick Timer (10ms) */1011 while(1) {1213 if (BTN_Pressed()) {14 ledVal += 1;15 if (ledVal > 3) ledVal = 1;16 }1718 if (ledBlink == 1) {19 ledBlink = 0;20 ledOn^= 1;21 if (ledOn == 1)22 LED_Out (ledVal); /* switch the LEDs on */23 else24 LED_Out (0); /* switch the LEDs off */2526 }27 }2829 }
  • 10. STM32 Discovery Kartı ile ilk adımlar – Co kun TA DEM R http://www.coskuntasdemir.net - 10 -1 #define LED_BLINK_RATE 10 /* rate = LED_BLINK_RATE * systick */2 #define LED_NUM 2 /* Number of user LEDs */3 const unsigned long led_mask[] = { 1UL<<8, 1UL<<9 }1 /*----------------------------------------------------------------------------2 Switch on LEDs3 *----------------------------------------------------------------------------*/4 __INLINE static void LED_On (uint32_t num) {56 GPIOC->BSRR = led_mask[num]; /* Turn On LED */7 }1 /*----------------------------------------------------------------------------2 Switch off LEDs3 *----------------------------------------------------------------------------*/4 __INLINE static void LED_Off (uint32_t num) {56 GPIOC->BRR = led_mask[num]; /* Turn Off LED */7 }1 /*----------------------------------------------------------------------------2 Function that outputs value to LEDs3 *----------------------------------------------------------------------------*/4 void LED_Out(uint32_t value) {5 int i;67 for (i = 0; i < LED_NUM; i++) {8 if (value & (1<<i)) {9 LED_On (i);10 } else {11 LED_Off(i);12 }13 }14 }
  • 11. STM32 Discovery Kartı ile ilk adımlar – Co kun TA DEM R http://www.coskuntasdemir.net - 11 -1 /*----------------------------------------------------------------------------2 configure Button pins3 *----------------------------------------------------------------------------*/4 __INLINE static void BTN_Config(void) {56 RCC->APB2ENR |= 1<<2; /* Enable GPIOA clock */7 GPIOA->CRL &= 0xFFFFFFF0; /* Configure the GPIO for BTNs */8 GPIOA->CRL |= 0x00000008; /* Configure the GPIO for BTNs */9 }1 /*----------------------------------------------------------------------------2 Read Button pins3 *----------------------------------------------------------------------------*/4 __INLINE static uint32_t BTN_Get(void) {56 return (GPIOA->IDR & 0x0001);78 }1 /*----------------------------------------------------------------------------2 USER1Pressed3 check if USER1 is pressed (unbounced).4 *----------------------------------------------------------------------------*/5 uint32_t BTN_Pressed (void) {6 static uint32_t USER1KeyCount = 0, USER1KeyPressed = 0;78 if (USER1KeyPressed) {9 if ((BTN_Get() == 0 )) { /* Check if USER1 not pressed */10 if (USER1KeyCount &lt; UNBOUNCE_CNT) USER1KeyCount++;11 else {12 USER1KeyPressed = 0;13 USER1KeyCount = 0;14 }15 }16 }17 else {18 if (!(BTN_Get() == 0 )) { /* Check if USER1 pressed */19 if (USER1KeyCount < UNBOUNCE_CNT) USER1KeyCount++;20 else {21 USER1KeyPressed = 1;22 USER1KeyCount = 0;
  • 12. STM32 Discovery Kartı ile ilk adımlar – Co kun TA DEM R http://www.coskuntasdemir.net - 12 -23 return (1);24 }25 }26 }27 return (0);28 }1 /*----------------------------------------------------------------------------2 /*----------------------------------------------------------------------------3 SysTick_Handler4 *----------------------------------------------------------------------------*/5 void SysTick_Handler (void) {6 static uint32_t ticks;78 if (ticks++ >= LED_BLINK_RATE) {9 ticks = 0;10 ledBlink = 1;11 }1213 }

×