I am using 32kHz mode for usart.
My procedure is
POWER_EnablePD(kPDRUNCFG_PD_XTAL32K); /*!< Powered down the XTAL 32 kHz RTC oscillator */
POWER_DisablePD(kPDRUNCFG_PD_FRO32K); /*!< Powered the FRO 32 kHz RTC oscillator */
CLOCK_AttachClk(kFRO32K_to_OSC32K); /*!< Switch OSC32K to FRO32K */
/*!< Set up dividers */
CLOCK_SetClkDiv(kCLOCK_DivAhbClk, 1U, false); /*!< Set AHBCLKDIV divider to value 1 */
/*!< Set up clock selectors - Attach clocks to the peripheries */
CLOCK_AttachClk(kOSC32K_to_MAIN_CLK); /*!< Switch MAIN_CLK to OSC32K */
/*< Set SystemCoreClock variable. */
SystemCoreClock = 32768U;
POWER_SetVoltageForFreq( 32768U ); /*!< Set voltage for the one of the fastest clock outputs: System clock output */
CLOCK_SetFLASHAccessCyclesForFreq(32768U); /*!< Set FLASH wait states for core */
CLOCK_SetClkDiv( kCLOCK_DivFlexFrg0, 256U, false ); /*!< Set FRGCTRL0_DIV divider to value 256 */
CLOCK_AttachClk( kOSC32K_to_FLEXCOMM0 );
USART_Init( BOARD_COMMS_UART, &config, CLOCK_GetFlexCommClkFreq( 0U ) );
if(CLOCK_GetFlexCommClkFreq( 0U ) == 32768U){
BOARD_COMMS_UART->CFG |= USART_CFG_MODE32K(1);
BOARD_COMMS_UART->BRG = 0;
}
I send a 16 byte of 0x55 in order to measure the baudrate, it gives me 0.49ms per bit, so the baud rate is 2000, not 9600.
I have also tested the CLKOUT which route to OSC32 clock, it gives me 32kHz correctly.
How can I set it to 9600 baud rate? Do I miss any steps to enable 32kHz clock mode for usart?
Do you have any example code?