AnsweredAssumed Answered

stm32f4: issues with rts/cts flow control with UART

Question asked by anglesmith.titanius on May 9, 2015
Latest reply on May 9, 2015 by Clive One
I am trying to get RTS/CTS working with UART3. I am using the MCBSTM32f400 (STM32F407VG) board and connected a serial cable on the UART3 with a PC. 

If i am not using the flow control on the PC side, i can get the MCU to accept data. But the RTS line seems to be kept high.

I am pretty sure i'm missing something trivial and it'll be great if someone could help me out.

Below is my code, which just tries to do basic read a single character from the PC
void HAL_UART_MspInit(UART_HandleTypeDef *huart)
    GPIO_InitTypeDef  GPIO_InitStruct;
    GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_PULLUP;
    GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
    GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
    GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_14;
    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
    GPIO_InitStruct.Alternate = GPIO_AF7_USART3;
    HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
UART_HandleTypeDef UartHandle;
int main(void)
    UartHandle.Instance          = USART3;
    UartHandle.Init.BaudRate     = 115200;
    UartHandle.Init.WordLength   = UART_WORDLENGTH_8B;
    UartHandle.Init.StopBits     = UART_STOPBITS_1;
    UartHandle.Init.Parity       = UART_PARITY_NONE;
    UartHandle.Init.HwFlowCtl    = UART_HWCONTROL_RTS_CTS;
    UartHandle.Init.Mode         = UART_MODE_TX_RX;
    UartHandle.Init.OverSampling = UART_OVERSAMPLING_16;
    if(HAL_UART_Init(&UartHandle) != HAL_OK) {
        /* Initialization Error */
        GLCD_DrawString         (0, 4*24, " UART NOT initialized   ");
    } else {
        GLCD_DrawString         (0, 4*24, " UART initialized   ");
    uint8_t SEND_DATA[] = {0x01, 0x03, 0x0c, 0x00};  
    HAL_UART_Transmit(&UartHandle, (uint8_t *)SEND_DATA, sizeof(SEND_DATA), 0xFFFF);
           //trasmit is successful

    unsigned char receive_queue, transmit_queue;
    while(1) {
        HAL_UART_Receive(&UartHandle, (uint8_t *)&receive_queue, 1, 0xFFFF);
          //receive is unsuccessful
        sprintf(ret_message, "USART msg# %hu  %c", msg_num++, receive_queue);
        GLCD_DrawString         (0, 7*24, (const char*)ret_message);         

Thanks for reading