<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>MCX Microcontrollers中的主题 LPUART RTS CTS not working</title>
    <link>https://community.nxp.com/t5/MCX-Microcontrollers/LPUART-RTS-CTS-not-working/m-p/2057337#M2604</link>
    <description>&lt;P&gt;I am trying to enable RTS/CTS flow control on LP FLEXCOMM2 UART on a FRDM-MCXN947 with the fsl_lpuart_freertos driver but I am getting&amp;nbsp;kStatus_LPUART_RxRingBufferOverrun.&lt;/P&gt;&lt;P&gt;I believe the pin_mux configuration (below) I have is correct but the logic analyzer never shows change to the RTS line.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;/* FUNCTION ************************************************************************************************************
 *
 * Function Name : UART_Pins
 * Description   : Configures pin routing and optionally pin electrical features.
 *
 * END ****************************************************************************************************************/
void UART_Pins(void)
{
    /* Enables the clock for PORT4: Enables clock */
    CLOCK_EnableClock(kCLOCK_Port4);

    /* PORT4_0 (pin P1) is configured as FC2_P0 */
    PORT_SetPinMux(UART_PINS_FC2_RX_PORT, UART_PINS_FC2_RX_PIN, kPORT_MuxAlt2);

    PORT4-&amp;gt;PCR[0] = ((PORT4-&amp;gt;PCR[0] &amp;amp;
                      /* Mask bits to zero which are setting */
                      (~(PORT_PCR_IBE_MASK)))

                     /* Input Buffer Enable: Enables. */
                     | PORT_PCR_IBE(PCR_IBE_ibe1));

    /* PORT4_1 (pin P2) is configured as FC2_P1 */
    PORT_SetPinMux(UART_PINS_FC2_TX_PORT, UART_PINS_FC2_TX_PIN, kPORT_MuxAlt2);

    PORT4-&amp;gt;PCR[1] = ((PORT4-&amp;gt;PCR[1] &amp;amp;
                      /* Mask bits to zero which are setting */
                      (~(PORT_PCR_IBE_MASK)))

                     /* Input Buffer Enable: Enables. */
                     | PORT_PCR_IBE(PCR_IBE_ibe1));

    /* PORT4_16 (pin R8) is configured as FC2_P2 */
    PORT_SetPinMux(UART_PINS_FC2_RTS_PORT, UART_PINS_FC2_RTS_PIN, kPORT_MuxAlt2);

    PORT4-&amp;gt;PCR[16] = ((PORT4-&amp;gt;PCR[16] &amp;amp;
                       /* Mask bits to zero which are setting */
                       (~(PORT_PCR_IBE_MASK)))

                      /* Input Buffer Enable: Enables. */
                      | PORT_PCR_IBE(PCR_IBE_ibe1));

    /* PORT4_17 (pin R9) is configured as FC2_P3 */
    PORT_SetPinMux(UART_PINS_FC2_CTS_PORT, UART_PINS_FC2_CTS_PIN, kPORT_MuxAlt2);

    PORT4-&amp;gt;PCR[17] = ((PORT4-&amp;gt;PCR[17] &amp;amp;
                       /* Mask bits to zero which are setting */
                       (~(PORT_PCR_IBE_MASK)))

                      /* Input Buffer Enable: Enables. */
                      | PORT_PCR_IBE(PCR_IBE_ibe1));
}
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Here is the flexcomm configuration in peripherals.c&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;/***********************************************************************************************************************
 * LP_FLEXCOMM2 initialization code
 **********************************************************************************************************************/
/* clang-format off */
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
instance:
- name: 'LP_FLEXCOMM2'
- type: 'lpflexcomm_lpuart'
- mode: 'freertos'
- custom_name_enabled: 'false'
- type_id: 'lpflexcomm_lpuart_2.3.0'
- functional_group: 'BOARD_InitPeripherals'
- peripheral: 'LP_FLEXCOMM2'
- config_sets:
  - fsl_lpuart_freertos:
    - lpuart_rtos_configuration:
      - timingConfig:
        - clockSource: 'LPFLEXCOMMFunctionClock'
        - lpuartSrcClkFreq: 'BOARD_BootClockPLL150M'
        - baudRateBpsStr: '115200'
      - parity: 'kLPUART_ParityDisabled'
      - stopbits: 'kLPUART_OneStopBit'
      - buffer_size: '512'
      - enableRxRTS: 'true'
      - enableTxCTS: 'true'
      - txCtsSource: 'kLPUART_CtsSourcePin'
      - txCtsConfig: 'kLPUART_CtsSampleAtStart'
      - rx_timeout_constant_ms: '0'
      - rx_timeout_multiplier_ms: '0'
      - tx_timeout_constant_ms: '0'
      - tx_timeout_multiplier_ms: '0'
    - interrupt_rx_tx:
      - IRQn: 'LP_FLEXCOMM2_IRQn'
      - enable_priority: 'false'
      - priority: '0'
 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
/* clang-format on */
lpuart_rtos_handle_t LP_FLEXCOMM2_rtos_handle;
lpuart_handle_t LP_FLEXCOMM2_lpuart_handle;
uint8_t LP_FLEXCOMM2_background_buffer[LP_FLEXCOMM2_BACKGROUND_BUFFER_SIZE];
lpuart_rtos_config_t LP_FLEXCOMM2_rtos_config = {
  .base = LP_FLEXCOMM2_PERIPHERAL,
  .srcclk = LP_FLEXCOMM2_CLOCK_SOURCE,
  .baudrate = 115200UL,
  .parity = kLPUART_ParityDisabled,
  .stopbits = kLPUART_OneStopBit,
  .buffer = LP_FLEXCOMM2_background_buffer,
  .buffer_size = 512UL,
  .enableRxRTS = true,
  .enableTxCTS = true,
  .txCtsSource = kLPUART_CtsSourcePin,
  .txCtsConfig = kLPUART_CtsSampleAtStart,
  .rx_timeout_constant_ms = 0UL,
  .rx_timeout_multiplier_ms = 0UL,
  .tx_timeout_constant_ms = 0UL,
  .tx_timeout_multiplier_ms = 0UL
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If RTS is working correctly then shouldn't the driver never overflow?&lt;/P&gt;</description>
    <pubDate>Thu, 06 Mar 2025 21:10:09 GMT</pubDate>
    <dc:creator>koj</dc:creator>
    <dc:date>2025-03-06T21:10:09Z</dc:date>
    <item>
      <title>LPUART RTS CTS not working</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/LPUART-RTS-CTS-not-working/m-p/2057337#M2604</link>
      <description>&lt;P&gt;I am trying to enable RTS/CTS flow control on LP FLEXCOMM2 UART on a FRDM-MCXN947 with the fsl_lpuart_freertos driver but I am getting&amp;nbsp;kStatus_LPUART_RxRingBufferOverrun.&lt;/P&gt;&lt;P&gt;I believe the pin_mux configuration (below) I have is correct but the logic analyzer never shows change to the RTS line.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;/* FUNCTION ************************************************************************************************************
 *
 * Function Name : UART_Pins
 * Description   : Configures pin routing and optionally pin electrical features.
 *
 * END ****************************************************************************************************************/
void UART_Pins(void)
{
    /* Enables the clock for PORT4: Enables clock */
    CLOCK_EnableClock(kCLOCK_Port4);

    /* PORT4_0 (pin P1) is configured as FC2_P0 */
    PORT_SetPinMux(UART_PINS_FC2_RX_PORT, UART_PINS_FC2_RX_PIN, kPORT_MuxAlt2);

    PORT4-&amp;gt;PCR[0] = ((PORT4-&amp;gt;PCR[0] &amp;amp;
                      /* Mask bits to zero which are setting */
                      (~(PORT_PCR_IBE_MASK)))

                     /* Input Buffer Enable: Enables. */
                     | PORT_PCR_IBE(PCR_IBE_ibe1));

    /* PORT4_1 (pin P2) is configured as FC2_P1 */
    PORT_SetPinMux(UART_PINS_FC2_TX_PORT, UART_PINS_FC2_TX_PIN, kPORT_MuxAlt2);

    PORT4-&amp;gt;PCR[1] = ((PORT4-&amp;gt;PCR[1] &amp;amp;
                      /* Mask bits to zero which are setting */
                      (~(PORT_PCR_IBE_MASK)))

                     /* Input Buffer Enable: Enables. */
                     | PORT_PCR_IBE(PCR_IBE_ibe1));

    /* PORT4_16 (pin R8) is configured as FC2_P2 */
    PORT_SetPinMux(UART_PINS_FC2_RTS_PORT, UART_PINS_FC2_RTS_PIN, kPORT_MuxAlt2);

    PORT4-&amp;gt;PCR[16] = ((PORT4-&amp;gt;PCR[16] &amp;amp;
                       /* Mask bits to zero which are setting */
                       (~(PORT_PCR_IBE_MASK)))

                      /* Input Buffer Enable: Enables. */
                      | PORT_PCR_IBE(PCR_IBE_ibe1));

    /* PORT4_17 (pin R9) is configured as FC2_P3 */
    PORT_SetPinMux(UART_PINS_FC2_CTS_PORT, UART_PINS_FC2_CTS_PIN, kPORT_MuxAlt2);

    PORT4-&amp;gt;PCR[17] = ((PORT4-&amp;gt;PCR[17] &amp;amp;
                       /* Mask bits to zero which are setting */
                       (~(PORT_PCR_IBE_MASK)))

                      /* Input Buffer Enable: Enables. */
                      | PORT_PCR_IBE(PCR_IBE_ibe1));
}
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Here is the flexcomm configuration in peripherals.c&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;/***********************************************************************************************************************
 * LP_FLEXCOMM2 initialization code
 **********************************************************************************************************************/
/* clang-format off */
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
instance:
- name: 'LP_FLEXCOMM2'
- type: 'lpflexcomm_lpuart'
- mode: 'freertos'
- custom_name_enabled: 'false'
- type_id: 'lpflexcomm_lpuart_2.3.0'
- functional_group: 'BOARD_InitPeripherals'
- peripheral: 'LP_FLEXCOMM2'
- config_sets:
  - fsl_lpuart_freertos:
    - lpuart_rtos_configuration:
      - timingConfig:
        - clockSource: 'LPFLEXCOMMFunctionClock'
        - lpuartSrcClkFreq: 'BOARD_BootClockPLL150M'
        - baudRateBpsStr: '115200'
      - parity: 'kLPUART_ParityDisabled'
      - stopbits: 'kLPUART_OneStopBit'
      - buffer_size: '512'
      - enableRxRTS: 'true'
      - enableTxCTS: 'true'
      - txCtsSource: 'kLPUART_CtsSourcePin'
      - txCtsConfig: 'kLPUART_CtsSampleAtStart'
      - rx_timeout_constant_ms: '0'
      - rx_timeout_multiplier_ms: '0'
      - tx_timeout_constant_ms: '0'
      - tx_timeout_multiplier_ms: '0'
    - interrupt_rx_tx:
      - IRQn: 'LP_FLEXCOMM2_IRQn'
      - enable_priority: 'false'
      - priority: '0'
 * BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
/* clang-format on */
lpuart_rtos_handle_t LP_FLEXCOMM2_rtos_handle;
lpuart_handle_t LP_FLEXCOMM2_lpuart_handle;
uint8_t LP_FLEXCOMM2_background_buffer[LP_FLEXCOMM2_BACKGROUND_BUFFER_SIZE];
lpuart_rtos_config_t LP_FLEXCOMM2_rtos_config = {
  .base = LP_FLEXCOMM2_PERIPHERAL,
  .srcclk = LP_FLEXCOMM2_CLOCK_SOURCE,
  .baudrate = 115200UL,
  .parity = kLPUART_ParityDisabled,
  .stopbits = kLPUART_OneStopBit,
  .buffer = LP_FLEXCOMM2_background_buffer,
  .buffer_size = 512UL,
  .enableRxRTS = true,
  .enableTxCTS = true,
  .txCtsSource = kLPUART_CtsSourcePin,
  .txCtsConfig = kLPUART_CtsSampleAtStart,
  .rx_timeout_constant_ms = 0UL,
  .rx_timeout_multiplier_ms = 0UL,
  .tx_timeout_constant_ms = 0UL,
  .tx_timeout_multiplier_ms = 0UL
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If RTS is working correctly then shouldn't the driver never overflow?&lt;/P&gt;</description>
      <pubDate>Thu, 06 Mar 2025 21:10:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/LPUART-RTS-CTS-not-working/m-p/2057337#M2604</guid>
      <dc:creator>koj</dc:creator>
      <dc:date>2025-03-06T21:10:09Z</dc:date>
    </item>
    <item>
      <title>Re: LPUART RTS CTS not working</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/LPUART-RTS-CTS-not-working/m-p/2057613#M2605</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/247711"&gt;@koj&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. First, i think you can refer to the&amp;nbsp;MCX Nx4x Reference Manual Chapter&amp;nbsp;66.5.2.3.3&lt;BR /&gt;Hardware flow control.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Snipaste_2025-03-07_15-12-30.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/327112iD65BE166F597728D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Snipaste_2025-03-07_15-12-30.png" alt="Snipaste_2025-03-07_15-12-30.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;2. Then&amp;nbsp;Check RTS/CTS Functionality with Logic Analyzer&lt;BR /&gt;Since your logic analyzer does not show RTS toggling. So you can use a simple test where you manually set/clear RTS.&lt;/P&gt;
&lt;P&gt;3.&amp;nbsp;Test with Bare-Metal Code&lt;/P&gt;
&lt;P&gt;You can test the SDK lpuart_polling example.&lt;/P&gt;
&lt;P&gt;This demo has&amp;nbsp;FSL_FEATURE_LPUART_HAS_MODEM_SUPPORT feature.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Snipaste_2025-03-07_15-20-18.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/327116iD4B233311D5C1834/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Snipaste_2025-03-07_15-20-18.png" alt="Snipaste_2025-03-07_15-20-18.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt; &lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Snipaste_2025-03-07_15-18-46.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/327113iF2D21FFDF5972019/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Snipaste_2025-03-07_15-18-46.png" alt="Snipaste_2025-03-07_15-18-46.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;You can config the&amp;nbsp;&lt;SPAN&gt;RTS/CTS pin and test this demo.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;BR&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Harry&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV id="tinyMceEditorHarry_Zhang_0" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Mar 2025 07:20:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/LPUART-RTS-CTS-not-working/m-p/2057613#M2605</guid>
      <dc:creator>Harry_Zhang</dc:creator>
      <dc:date>2025-03-07T07:20:53Z</dc:date>
    </item>
    <item>
      <title>Re: LPUART RTS CTS not working</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/LPUART-RTS-CTS-not-working/m-p/2058072#M2616</link>
      <description>&lt;P&gt;After taking the time to debug this I see that the fsl_lpuart_freertos.c uses the fsl_lpuart.c ring buffer feature and the LPUART_TransferHandleIRQ doesn't stop reading from the UART-&amp;gt;DATA when the ring buffer is full.&amp;nbsp; The IRQ Handler just reports an overrun, which the LPUART_RTOS_Callback() uses to eventually abort the Receive, and overwrites the the oldest data instead.&lt;/P&gt;&lt;P&gt;Since the DATA is always read the RTS line is never deasserted because the STAT[RDRF] is never 1.&lt;/P&gt;&lt;P&gt;The fsl_lpuart.c driver only sets the MODIR[RXRTSE] during init, and doesn't consider flow control fully.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Mar 2025 18:28:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/LPUART-RTS-CTS-not-working/m-p/2058072#M2616</guid>
      <dc:creator>koj</dc:creator>
      <dc:date>2025-03-07T18:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: LPUART RTS CTS not working</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/LPUART-RTS-CTS-not-working/m-p/2062150#M2679</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/247711"&gt;@koj&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"&lt;SPAN&gt;The fsl_lpuart.c driver only sets the MODIR[RXRTSE] during init, and doesn't consider flow control fully.&lt;/SPAN&gt;"&lt;/P&gt;
&lt;P&gt;If you enable the&amp;nbsp;&lt;SPAN&gt;RxRTS and&amp;nbsp;TxCTS in the&amp;nbsp;LPUART_Init.&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;        /* Set the CTS configuration/TX CTS source. */
        base-&amp;gt;MODIR |= LPUART_MODIR_TXCTSC(config-&amp;gt;txCtsConfig) | LPUART_MODIR_TXCTSSRC(config-&amp;gt;txCtsSource);
        if (true == config-&amp;gt;enableRxRTS)
        {
            /* Enable the receiver RTS(request-to-send) function. */
            base-&amp;gt;MODIR |= LPUART_MODIR_RXRTSE_MASK;
        }
        if (true == config-&amp;gt;enableTxCTS)
        {
            /* Enable the CTS(clear-to-send) function. */
            base-&amp;gt;MODIR |= LPUART_MODIR_TXCTSE_MASK;
        }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;Do you mean this won't work?&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Harry&lt;/P&gt;</description>
      <pubDate>Fri, 14 Mar 2025 14:45:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/LPUART-RTS-CTS-not-working/m-p/2062150#M2679</guid>
      <dc:creator>Harry_Zhang</dc:creator>
      <dc:date>2025-03-14T14:45:32Z</dc:date>
    </item>
    <item>
      <title>Re: LPUART RTS CTS not working</title>
      <link>https://community.nxp.com/t5/MCX-Microcontrollers/LPUART-RTS-CTS-not-working/m-p/2062247#M2683</link>
      <description>&lt;P&gt;I'm saying the RTS flow control is not compatible with the ring buffer configuration since the reading doesn't stop when the ring is full.&lt;/P&gt;&lt;P&gt;If the ring is full and flow control is enabled, the reading from the UART FIFO (read data register) should stop instead of overwriting the oldest data in the ring buffer.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Mar 2025 17:28:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MCX-Microcontrollers/LPUART-RTS-CTS-not-working/m-p/2062247#M2683</guid>
      <dc:creator>koj</dc:creator>
      <dc:date>2025-03-14T17:28:32Z</dc:date>
    </item>
  </channel>
</rss>

