AnsweredAssumed Answered

Half-duplex USART ?

Question asked by rousseaux.sebastien on Feb 11, 2014
Latest reply on Feb 12, 2014 by Clive One
Hi,

I'd like to use the USART3 of the STM32F407 (Discovery Board) in Half Duplex to control a Dynamixel AX12A.

My USART initialization is the following:
void USART3_init(void)
{
 
    GPIO_InitTypeDef GPIO_InitStructure;
    USART_InitTypeDef USART_InitStructure;
 
    /* Enable GPIO clock */
    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);
 
    /* Enable UART clock */
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
 
    /* Connect PXx to USARTx_Tx*/
    GPIO_PinAFConfig(GPIOD, GPIO_PinSource8, GPIO_AF_USART3);
 
    /* Configure USART Tx as alternate function  */
    GPIO_InitStructure.GPIO_OType = GPIO_Mode_IN; // Input (could also use Open Drain)
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
 
    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
    GPIO_Init(GPIOD, &GPIO_InitStructure);
 
    USART_InitStructure.USART_BaudRate              = 1000000;
    USART_InitStructure.USART_WordLength            = USART_WordLength_8b;
    USART_InitStructure.USART_StopBits              = USART_StopBits_1;
    USART_InitStructure.USART_Parity                = USART_Parity_No;
    USART_InitStructure.USART_HardwareFlowControl   = USART_HardwareFlowControl_None;
    USART_InitStructure.USART_Mode                  = USART_Mode_Rx | USART_Mode_Tx;
    USART_HalfDuplexCmd(USART3, ENABLE);           
 
    /* USART configuration */
    USART_Init(USART3, &USART_InitStructure);
 
    /* Enable USART */
    USART_Cmd(USART3, ENABLE);
}

The TX part seems to work fine.

The problem is that the device answers (oscilloscope) but I have no RX flag when doing a simple check:
while (USART_GetFlagStatus(USART3, USART_FLAG_RXNE) == RESET);

Is my configuration correct ? How can I activate the RX part ?
And also, is there any trick to disable/enable RX on the fly ? (I can get a RX flag on my own emission but not on the answer)

Thanks!

Outcomes