STM32F100RB , GPIOA nur Input?

Gast #2161614
Lesenswert?

Hallo,

ich versuche mich gerade mit dem tollen STM32 und bin auch sehr 
begeistert. Leider läßt sich bei meinen Discovery-Board der PORTA nicht 
also Output schalten. Kann es sein, dass der PORTA/GPIOA nur als Input 
zu verwenden ist? Clock ist enabled und die CRH,CRL-Register sind wie 
bei den anderen GPIOxs auf

  GPIOA->CRH = 0x11111111;
  GPIOA->CRL = 0x11111111;

Mit
    RCC->APB2ENR |= 1 << 2; // Enable GPIOA clock

enable ich den Clock zm GPIOA

und mit

  GPIOA->BSRR =   0x0000FFFF;

setze ich den ganze Port auf High und mit

   GPIOA->BRR  = 0x0000FFFF;

wieder auf Low. Leider zuckt da nix auf der Leitung. Hm...
Gast #2209747
Lesenswert?

Ich nutze gerade den USART2, welcher an Port A hängt.
Dort funktioniert auch der Ausgang...

Ich verwende allerdings die abstrakteren Funktionen der stlib:
1
/***************************************************************************//**
2
 * Global macros
3
 ******************************************************************************/
4

5
#define LED_PORT    GPIOC
6
#define BUTTON_PORT GPIOA
7

8
#define LED_BLUE    GPIO_Pin_8
9
#define LED_GREEN   GPIO_Pin_9
10

11
#define BUTTON_BLUE GPIO_Pin_0
12

13
[...]
14

15
    /* Enable GPIO clock */
16
    RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOC, ENABLE);
17
    RCC_APB1PeriphClockCmd( RCC_APB1Periph_USART2, ENABLE);
18

19
    // Port C -> LEDs
20
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
21
    GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_Out_PP;
22
    GPIO_InitStructure.GPIO_Pin   = LED_GREEN | LED_BLUE;
23
    GPIO_Init(LED_PORT, &GPIO_InitStructure);
24

25
    // Port A -> blue button
26
    GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_IN_FLOATING;
27
    GPIO_InitStructure.GPIO_Pin   = BUTTON_BLUE;
28
    GPIO_Init(BUTTON_PORT, &GPIO_InitStructure);
29

30
    /* Configure USART2 Rx (PA3) as input floating                         */
31
    GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_3;
32
    GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_IN_FLOATING;
33
    GPIO_Init(GPIOA, &GPIO_InitStructure);
34

35
    /* Configure USART2 Tx (PA2) as alternate function push-pull            */
36
    GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_2;
37
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;
38
    GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AF_PP;
39
    GPIO_Init(GPIOA, &GPIO_InitStructure);
40

41
    /* USART2 configured as follow:
42
          - BaudRate = 115200 baud
43
          - Word Length = 8 Bits
44
          - One Stop Bit
45
          - No parity
46
          - Hardware flow control disabled (RTS and CTS signals)
47
          - Receive and transmit enabled
48
          - USART Clock disabled
49
          - USART CPOL: Clock is active low
50
          - USART CPHA: Data is captured on the middle
51
          - USART LastBit: The clock pulse of the last data bit is not output to
52
                           the SCLK pin
53
    */
54
    USART_InitStructure.USART_BaudRate            = 115200;
55
    USART_InitStructure.USART_WordLength          = USART_WordLength_8b;
56
    USART_InitStructure.USART_StopBits            = USART_StopBits_1;
57
    USART_InitStructure.USART_Parity              = USART_Parity_No ;
58
    USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
59
    USART_InitStructure.USART_Mode                = USART_Mode_Rx | USART_Mode_Tx;
60
    USART_Init(USART2, &USART_InitStructure);
61
    USART_Cmd( USART2, ENABLE);

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