STM32 und Coocox: LED blinkt nicht

OP #3065830
Lesenswert?
• ▲
▼
Hallo,

wie der Titel schon sagt, versuche ich eine LED zum Blinken zu bringen.

Leider blinkt da gar nichts.

Compiler/Linker/Flashen sieht gut aus, aber trotzdem blinkt nichts.

LED hängt an PB11 über 1k an GND.
1
#include "stm32f10x.h"
2
#include "stm32f10x_gpio.h"
3
#include "stm32f10x_rcc.h"
4

5
int main(void) {
6
  int i;
7

8
  /* Initialize Leds mounted on STM32 board */
9
  GPIO_InitTypeDef GPIO_InitStructure;
10

11
  /* Initialize LED which connected to PB11, Enable the Clock*/
12
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
13

14
  /* Configure the GPIO_LED pin */
15
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
16
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
17
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
18
  GPIO_Init(GPIOB, &GPIO_InitStructure);
19

20
  while (1) {
21

22
    GPIO_WriteBit(GPIOB, GPIO_Pin_11, Bit_SET);
23
    for (i = 0; i < 1000000; i++)
24
      ;
25
    GPIO_WriteBit(GPIOB, GPIO_Pin_11, Bit_RESET);
26
    for (i = 0; i < 1000000; i++)
27
      ;
28

29
  }
30
}

Ich verwende die Coocox 1.7.0 IDE mit GCC 4.7 Toolchain (-O0).

Fehlt noch etwas an Initialisierung?

5x Stromversorgung und Abblockkondensatoren sind vorhanden. MC ist ein 
STM32F107RC. Es ist ein Quarz mit 25Mhz un 2x22pf angeschlossen.

Flasher ist der ST-Link vom STM32F4-Discovery.
Angehängte Dateien:
OP #3065963
Lesenswert?
• ▲
▼
Ich habe die LED auch mal an PIN10 geschaltet und das Programm geändert, 
keine Reaktion.

Ja, es sind die einzigen Zeilen in main.c.

Mit volatile keine Änderung.

Die SysClock startet doch in startup_stm32f10x_cl.c, mein Verdacht ist, 
dass der µC gar nicht läuft (geht dann das Flashen?)
Persönliche Seite #3066020
Lesenswert?
• ▲
▼
hi,

also ich hab das auch mal mit einer for-Schleife gemacht so wie du, 
allerdings habe ich GPIO_ToggleBits(GPIOD,GPIO_Pin_X); benutzt und es 
hat funktioniert.
Ergänze mal noch eine Zeile für die PORT-Init, mit folgendem:
1
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;


Vielleicht ist ein Pull Up/Down aktiv und die sind recht hochohmig, aufm 
Discoveryboard z.b. leuchten die LEDs dann fast nicht mehr und ich hatte 
keine Compiler Optimierung.
OP #3066034
Lesenswert?
• ▲
▼
Das gibt meine Structure nicht her:
1
typedef struct
2
{
3
  uint16_t GPIO_Pin;             /*!< Specifies the GPIO pins to be configured.
4
                                      This parameter can be any value of @ref GPIO_pins_define */
5

6
  GPIOSpeed_TypeDef GPIO_Speed;  /*!< Specifies the speed for the selected pins.
7
                                      This parameter can be a value of @ref GPIOSpeed_TypeDef */
8

9
  GPIOMode_TypeDef GPIO_Mode;    /*!< Specifies the operating mode for the selected pins.
10
                                      This parameter can be a value of @ref GPIOMode_TypeDef */
11
}GPIO_InitTypeDef;
Persönliche Seite #3066047
Lesenswert?
• ▲
▼
also bei mir gibts noch dass hier:
1
typedef struct
2
{
3
  uint32_t GPIO_Pin;              /*!< Specifies the GPIO pins to be configured.
4
                                       This parameter can be any value of @ref GPIO_pins_define */
5

6
  GPIOMode_TypeDef GPIO_Mode;     /*!< Specifies the operating mode for the selected pins.
7
                                       This parameter can be a value of @ref GPIOMode_TypeDef */
8

9
  GPIOSpeed_TypeDef GPIO_Speed;   /*!< Specifies the speed for the selected pins.
10
                                       This parameter can be a value of @ref GPIOSpeed_TypeDef */
11

12
  GPIOOType_TypeDef GPIO_OType;   /*!< Specifies the operating output type for the selected pins.
13
                                       This parameter can be a value of @ref GPIOOType_TypeDef */
14

15
  GPIOPuPd_TypeDef GPIO_PuPd;     /*!< Specifies the operating Pull-up/Pull down for the selected pins.
16
                                       This parameter can be a value of @ref GPIOPuPd_TypeDef */
17
}GPIO_InitTypeDef;

Welche Version von der CooIDE hast du?

Antwort schreiben

Hinweis: der ursprüngliche Beitrag ist mehr als 6 Monate alt. Bitte hier nur auf die ursprüngliche Frage antworten, für neue Fragen einen neuen Beitrag erstellen.

Formatierung
  • [c]C-Code[/c]
  • [code]Code in anderen Sprachen, ASCII-Zeichnungen[/code]
  • [math]Formel in LaTeX-Syntax[/math]
  • [[Titel]] – Link zu einem Artikel
  • Verweis auf einen anderen Beitrag: Rechtsklick auf dessen Beitrags-ID (#8078628), „Adresse kopieren“, in den Text einfügen

Mehr zur Formatierung

Längeren Sourcecode als Anhang, nicht in den Text. JPG nur für Fotos und Scans; Zeichnungen und Screenshots als PNG oder GIF. Siehe Bildformate.

Schon registriert? Anmelden

Wird nicht angezeigt. Wir schicken dir einen Link; sobald du damit bestätigst, erscheint dein Beitrag.

Mit dem Abschicken legst du einen kostenlosen Account an und erkennst die Nutzungsbedingungen und die Datenschutzerklärung an.