STM32 Delay funktion arbeitet nicht

OP #3177148
Lesenswert?

Ich habe folgenden Code:
1
#include "stm32f4xx_conf.h"
2

3
const uint32_t one_tick = 1 / 8000000 * 1000; //1/F = t, müsste die Zeit für einen Tick in ms sein
4

5
void _delay_ms(__IO uint32_t time){
6
  uint32_t loops = time / one_tick;
7
  for(uint32_t i = 0; i < loops; i++){
8
    __asm("nop");
9
  }
10
}
11

12
void GPIO_Init_Pins(void){
13
  GPIO_InitTypeDef GPIO_InitStructure;
14

15
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
16

17
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14;
18
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
19
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
20
  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
21
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
22
  GPIO_Init(GPIOD, &GPIO_InitStructure);
23
}
24

25
int main(void){
26

27
  SystemInit();
28

29
  GPIO_Init_Pins();
30

31
    while(1){
32
      GPIO_SetBits(GPIOD, GPIO_Pin_14);
33
      _delay_ms(1000);
34
      GPIO_ResetBits(GPIOD, GPIO_Pin_14);
35
      _delay_ms(1000);
36
    }
37
}
Wenn ich aber Compiliere und brenne, ist der Pin dauerhaft an. 
Eigentlich sollte er im Sekundentakt blinken

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren