AnsweredAssumed Answered

nRTS / nCTS behavior is NOT expectation

Question asked by E-John on Aug 9, 2017
Latest reply on Aug 16, 2017 by E-John

Dear SIR,

 

Issue : nRTS / nCTS behavior is NOT expectation,

 

description:

while(1){} empty loop is running on MCU, data is not taken from USART->RDR.
The expectation is nRTS is set to high until the data is read from USART->RDR
but the real case is the nRTS is asserted(tied low) after 500ms.

Is there any missing?

 

Block diagream is as follows,
Set UART to hardware control flow mode on PC side and STM32F030C6T6 side both

    PC                 USB-Serial bridge
+--------+          +--------+ PC_TX     MCU_RX   +--------+
|        |          |        | -----------------> |        |
|        |          |        | PC_RX     MCU_TX   |        |
|        | USB I/F  |        | <----------------- |        |
|        |<-------->|        | PC_nRTS   MCU_nCTS |  MCU   |
|        |          |        | -----------------> |        |
|        |          |        | PC_nCTS   MCT_nRTS |        |
|        |          |        |<-----------------  |        |
+--------+          +--------+                    +--------+
Fig.1 Block diagram between PC and STM32F030CT6


   ---+ start +------------------------+------+------+ start +------------------------
RX    | bit   |        Data 1          | stop   idle | bit   |        Data 2
      +-------+------------------------+             +-------+------------------------+

                                           +------+
nRTS                                       |      |
    ---------------------------------------+      +------------------------------
                                           ^      ^
                                           |      |
                      RXNE from low to high       Data 1 read,
                                                  Data 2 can now be transmitted

Fig.2
nRTS is de-asserted, indicating that the transmission is expected to stop at current frame.

 

USART setting

/* USART1 init function */
static void MX_USART1_UART_Init(void)
{

huart1.Instance = USART1;
huart1.Init.BaudRate = 115200;
huart1.Init.WordLength = UART_WORDLENGTH_8B;
huart1.Init.StopBits = UART_STOPBITS_1;
huart1.Init.Parity = UART_PARITY_NONE;
huart1.Init.Mode = UART_MODE_TX_RX;
huart1.Init.HwFlowCtl = UART_HWCONTROL_RTS_CTS;
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&huart1) != HAL_OK)
{
_Error_Handler(__FILE__, __LINE__);
}

}

 

Thanks and regards,

E-John

Outcomes