Hallo liebes Forum,
aller Anfang ist schwer, so auch beim STM32. Nachdem ich jetzt mehrere
Blinkprogramme ausprobiert habe, und es auch geschafft hab, eine Led
anzumachen, klappt das Ganze aber nicht mit dem Blinkten. Ich verwende
einen STM32F103VC mit einer LED an PinB0. Als IDE verwende ich CooCox.
Was läuft da schief?
1 | #include <stm32f10x_conf.h>
|
2 |
|
3 |
|
4 | void delayLoop() {
|
5 | volatile uint32_t delayCount = 100000000000; // volatile, um "Wegoptimieren" zu vermeinden
|
6 | //(http://en.wikipedia.org/wiki/Volatile_variable)
|
7 | while (delayCount > 0) {
|
8 | delayCount--;
|
9 | }
|
10 | }
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | int main(void)
|
16 | {
|
17 | GPIO_InitTypeDef GPIO_InitStructure;
|
18 |
|
19 | SystemInit();
|
20 |
|
21 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
|
22 |
|
23 | GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
|
24 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
|
25 | GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
26 | GPIO_Init(GPIOB, &GPIO_InitStructure);
|
27 |
|
28 | while(1)
|
29 | {
|
30 | GPIO_WriteBit(GPIOB, GPIO_Pin_0, Bit_SET);
|
31 | delayLoop();
|
32 | GPIO_WriteBit(GPIOB, GPIO_Pin_0, Bit_RESET);
|
33 | delayLoop();
|
34 | }
|
35 | }
|