1.34.27.12 1.35.21.12 USARTx_SerialSetup Function

C

/* x = USART instance number */

/* Blocking, non-blocking and ring buffer mode */
void USARTx_SerialSetup(USART_SERIAL_SETUP * setup, uint32_t srcClkFreq)

Summary

Sets up serial configurations for USART peripheral.

Description

This function sets the serial configurations of the peripheral. It provides run-time interface to configure the baud, parity, stop bits and data character size parameters of the serial connection. Calling this function when a serial communication is in progress can disrupt the communication. The caller should ensure that there is no serial communication in progress. In case of success, the function will update all parameters specified in the setup parameter, even if some parameter may have not changed since a previous call to this function. In case of failure, all parameters stay unchanged.

Precondition

USARTx_Initialize must have been called for the associated USART instance. The USART transmit or receive transfer status should not be busy.

Parameters

Param Description
setup Pointer to serial configuration data structure
srcClkFreq Input clock frequency to the Baud Rate Generator. If configured to zero PLIB takes the peripheral clock frequency from MHC.

Returns

true - Serial configuration was successful

false - The specified serial configuration could not be supported. This, for example, could happen if the requested baud is not supported.

Example

USART_SERIAL_SETUP setup = {
    115200,
    USART_DATA_8_BIT,
    USART_PARITY_ODD,
    USART_STOP_1_BIT
};

USART1_SerialSetup(&setup, 0);

Remarks

None