APIs for enabling, and disabling UART receiver, and clearing UART receive flags

Hi,

I am currently using EK-RA2A1 dev kit. I have an application where I need to disable the UART receiver while transmitting data. My application uses half-duplex mode where-in the Rx and Tx lines are connected together wherein I'm receiving anything I transmit. I am able to use R_BSP_IrqDisable and R_BSP_IrqEnable to at least minimize the overhead of getting receive ISRs while transmitting. However, I am unable to clear any receive errors before re-enabling the receive interrupt without having to duplicate the SCI_SSR bit masks as the following are not made available in the r_sci_uart.h file:

#define SCI_SSR_ORER_MASK (0x20U) ///< overflow error
#define SCI_SSR_FER_MASK (0x10U) ///< framing error
#define SCI_SSR_PER_MASK (0x08U) ///< parity err
#define SCI_SSR_FIFO_RESERVED_MASK (0x02U) ///< Reserved bit mask for SSR_FIFO register
#define SCI_RCVR_ERR_MASK (SCI_SSR_ORER_MASK | SCI_SSR_FER_MASK | SCI_SSR_PER_MASK)

It would really be nice to have APIs added to enable and disable UART receiver and receive interrupts, as well as clearing UART receive error and RDRF flags.

  • Hello,

    I am not expert but I just want to say that It sounds like you are trying to disable the UART receiver while transmitting data in order to avoid receiving any data while transmitting. You mentioned that you are using the EK-RA2A1 dev kit, so I assume that you are using Renesas' SCI (Serial Communication Interface) module for UART communication.

    To disable the UART receiver, you can use the SCI SCR (Serial Control Register) register. To disable the receiver, you need to clear the RE (Receiver Enable) bit in the SCR register. Here is an example code to disable the receiver:

    SCI0.SCR.BIT.RE = 0; // Disable receiver

    To enable the UART receiver, you can set the RE bit in the SCR register. Here is an example code to enable the receiver:

    SCI0.SCR.BIT.RE = 1; // Enable receiver

    To clear any receive errors, you can read the SCI SSR (Serial Status Register) register. Reading this register clears any error flags in the register. Here is an example code to clear the receive errors:

    uint8_t dummy_data = SCI0.RDR; // Read the RDR register to clear any error flags

    To clear the RDRF (Receive Data Register Full) flag, you can read the SCI RDR (Receive Data Register) register. Reading this register clears the RDRF flag. Here is an example code to clear the RDRF flag:

    uint8_t received_data = SCI0.RDR; // Read the RDR register to clear the RDRF flag

    Regarding adding APIs for enabling and disabling the UART receiver and receive interrupts, you can create your own functions that set or clear the appropriate bits in the SCI SCR register. Here is an example code to disable the receiver using a function:

    void disable_uart_receiver(void
    {
            SCI0.SCR.BIT.RE = 0; // Disable receiver
    }

    I hope this helps!

  • Hello,

    Thanks for posting your question online.

    There are not APIs provided from FSP that can disable only the reception or the receive interrupt.

    As mentioned above, this can be done from register level access and specifically from RE and RIE bits of SCR register:

    The same applies for RDRF flag and error flags: 

    Please let us know if you need something more.

    Regards