Hallo,
ich habe heute versucht eine von den LEDs am STM32F4 Discovery Board ein
und nach einer bestimmten Zeit (1Sekunde) wieder auszuschalten und dann
wieder nach 1s einzuschalten und das unbegrenzt oft.
Ich habe in den Beispielen von Keil eine Variante gefunden die in dem
Beispielprogramm auch funktioinert hat nur jetzt, wo ich das in mein
Prog eingefügt habe gehts natürlich wieder nicht.
Kann mir jemand sagen was ich da falsch mache?
1 | #include <stm32f4xx.h>
|
2 | #include <stm32f4xx_gpio.h>
|
3 | #include <stm32f4xx_rcc.h>
|
4 | #include <stm32f4xx_conf.h>
|
5 | #include <LED.h>
|
6 | #include <stdio.h>
|
7 |
|
8 |
|
9 | /** @addtogroup STM32F4_Discovery_Peripheral_Examples
|
10 | * @{
|
11 | */
|
12 |
|
13 | /** @addtogroup IO_Toggle
|
14 | * @{
|
15 | */
|
16 | int leuchtdauer =0;
|
17 | int initialised = 0;
|
18 | int bts = 0;
|
19 | uint32_t ms = 1000;
|
20 | unsigned int kled = 0;
|
21 |
|
22 |
|
23 | volatile uint32_t msTicks; // Counts 1ms timeTicks
|
24 |
|
25 | void SysTick_Handler (void) {
|
26 | msTicks++; // increment Delay()-counter
|
27 | }
|
28 |
|
29 |
|
30 | __INLINE static void Delay (uint32_t dlyTicks) {
|
31 | uint32_t curTicks;
|
32 |
|
33 | curTicks = msTicks;
|
34 | while ((msTicks - curTicks) < dlyTicks);
|
35 | }
|
36 |
|
37 | GPIO_InitTypeDef GPIO_InitStructure;
|
38 |
|
39 |
|
40 | void Delay(__IO uint32_t nCount);
|
41 |
|
42 |
|
43 | int main(void)
|
44 | {
|
45 | if(initialised == 0){
|
46 | LED_Init();
|
47 | BTN_Init();
|
48 | initialised = 1;
|
49 | }
|
50 |
|
51 |
|
52 | while(1){
|
53 | LED_On(1);
|
54 | Delay(1000);
|
55 |
|
56 | LED_Off(1);
|
57 | Delay(1000);
|
58 |
|
59 | }
|
60 |
|
61 |
|
62 | }
|