Forum: Mikrocontroller und Digitale Elektronik STM32F2xx: UART in Half Duplex


von Connector (Gast)


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

von Mike (Gast)


Lesenswert?

Interrupt-Modus für RX unf TX nutzen!

von Mike (Gast)


Lesenswert?


von Connector (Gast)


Lesenswert?

Mike schrieb:
> Interrupt-Modus für RX unf TX nutzen!

Wie du meinen!?

von Connector (Gast)


Lesenswert?

Mike schrieb:
> Beispiel: Beitrag "Re: STM32F4Discovery mit CooCox CoOS-RTOS und printf"

Bei dem im dem Paket enthaltene uart.c wird der Half Duplex Mode nicht 
verwendet.

von Jim M. (turboj)


Lesenswert?

Connector schrieb:
> kommt nur Müll auf dem TX-Pin raus. :-(

Wie sieht dieser Müll auf dem Oszilloskop aus? Eventuell ist ja nur der 
Pullup zu groß, für normale Baudraten wie 115200 brauchst Du einen 
externen Pullup Widerstand.

Ansonsten ist die Frage ohne Schaltplan oder ploierte Glaskugel nicht 
ohne weiteres zu beantworten.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.