stm Discovery läuft nicht

Gast #4213306
Lesenswert?
• ▲
▼
Hallo,

ich habe ein STM32F100RB Discovery Board. Dies hat am Port PC9 sowie PC8 
jeweils eine LED.

Um diese zu aktivieren habe ich folgenden Code:
1
#include <stdio.h>
2
#include <stdlib.h>
3
#include "stm32f10x_conf.h"
4

5
void intled() {
6
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
7

8
    GPIO_InitTypeDef GPIO_InitStructure;
9
    GPIO_StructInit (&GPIO_InitStructure);
10
    // Configure pin in output push/pull mode
11
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9;
12
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
13
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
14
    GPIO_Init(GPIOC, &GPIO_InitStructure);
15

16

17
}
18
int main()
19
{
20
  SystemInit();
21
  SysTick_Config(SystemCoreClock/100);
22
 intled();
23

24
  while (1)
25
    {
26
GPIO_SetBits(GPIOC,GPIO_Pin_8);
27
GPIO_SetBits(GPIOC,GPIO_Pin_9);
28
    }
29
}

Ich nutze unter Linux Eclipse mit dem ARM Plugin sowie den GCC ARM.
In Eclipse habe ich eingestellt das er mir ein Binary File erstellen 
soll, welche ich anschließend mit st-flash write file.bin 0x8000000 auf 
den arm schiebe. Laut Ausgabe gibt es auch keinen Fehler. Leider 
passiert IC mäßig nichts die LEDs schalten sich nicht ein, auch nicht 
nachdem ich mehrmals den Reset Button gedrückt habe....
Muss man noch etwas spezielles beachten? Ich bin noch Anfänger.
#4215652
Lesenswert?
• ▲
▼
Die Systick Configuration könnte dich ohne entsprechenden Handler 
umbringen,
lies: Das Programm bleibt im Default Handler (meist Endlosschleife) 
hängen.

Versuche mal die GPIOs auf Low zu setzen, oft sind LEDs nach VCC und 
nicht nach Masse geschaltet (active Low). Müsste man im Schaltplan 
sehen.
(Firma: matzetronics) #4216296
Lesenswert?
• ▲
▼
Füge das noch am Anfang der main() ein:
1
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
Alsdann evtl. den Systick Handler und seine Helferlein:
1
static __IO uint32_t TimingDelay;
2
/**
3
  * @brief  Inserts a delay time.
4
  * @param  nTime: specifies the delay time length, in milliseconds.
5
  * @retval None
6
  */
7
void Delay(uint32_t nTime)
8
{ 
9
  TimingDelay = nTime;
10

11
  while(TimingDelay != 0);
12
}
13
/**
14
  * @brief  Decrements the TimingDelay variable.
15
  * @param  None
16
  * @retval None
17
  */
18
void TimingDelay_Decrement(void)
19
{
20
  if (TimingDelay != 0x00)
21
  { 
22
    TimingDelay--;
23
  }
24
}
25
/**
26
  * @brief  This function handles SysTick Handler.
27
  * @param  None
28
  * @retval None
29
  */
30
void SysTick_Handler(void)
31
{
32
  TimingDelay_Decrement();
33
}
Hier mit den original Kommentaren der Discovery VL Jungs.

Jim M. schrieb:
> Versuche mal die GPIOs auf Low zu setzen, oft sind LEDs nach VCC und
> nicht nach Masse geschaltet (active Low). Müsste man im Schaltplan
> sehen.

Das VL Discovery legt die LED auf Masse, ein High am Portpin sollte sie 
schon zum leuchten bringen, das stimmt also so.
Empfehlenswert ist Application Note UM919 aber immer, dadrin sind die 
Schaltpläne.

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