STM32F2xx: UART in Half Duplex

Gast #3291518
Lesenswert?

Hallo!

Wie muss ich die GPIO und den UART richtig konfigurieren, so dass er im 
Half Duplex Mode läuft?
Mit:
1
  /* Enable GPIO clock */  
2
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
3
  /* Enable UART clock */
4
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART6, ENABLE);   
5

6
  GPIO_InitStructure.GPIO_OType = GPIO_OType_OD;
7
  GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_UP;
8
  GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AF;
9
  GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_6;
10
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
11
  GPIO_Init(GPIOC, &GPIO_InitStructure);
12

13
  /* Connect PXx to USARTx_Tx*/
14
  GPIO_PinAFConfig(GPIOC, GPIO_PinSource6, GPIO_AF_USART6);  
15

16
  USART6->CR3 |= USART_CR3_HDSEL; /* Half-Duplex */
kommt nur Müll auf dem TX-Pin raus. :-(

Belasse ich die Konfiguration bei Full-Duplex geht alles:
1
  /* Enable GPIO clock */  
2
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE);
3
  /* Enable UART clock */
4
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART6, ENABLE);   
5

6
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
7
  GPIO_InitStructure.GPIO_PuPd  = GPIO_PuPd_UP;
8
  GPIO_InitStructure.GPIO_Mode  = GPIO_Mode_AF;
9
  GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_6;
10
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
11
  GPIO_Init(GPIOC, &GPIO_InitStructure);
12
  GPIO_InitStructure.GPIO_Pin   = GPIO_Pin_7;
13
  GPIO_Init(GPIOC, &GPIO_InitStructure);
14

15
  /* Connect PXx to USARTx_Tx*/
16
  GPIO_PinAFConfig(GPIOC, GPIO_PinSource6, GPIO_AF_USART6);  
17
  /* Connect PXx to USARTx_Rx*/
18
  GPIO_PinAFConfig(GPIOC, GPIO_PinSource7, GPIO_AF_USART6);

Eigentlich lasse ich nur die RX-Pin Konfiguration weg und mache aus dem 
TX-Pin ein Open Drain, wie es in der Anleitung steht:
> It means that the I/O must be configured so that TX is
> configured as floating input (or output high open-drain)
> when not driven by the USART.

Danke für die Hilfe!

Gruß
Connector

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