UART and LOGUART

For peripherals that require specific clock settings, such as UART and LOGUART, the configuration procedures are described in the following sections.

  1. Initialize UART/LOGUART and enable their interrupts.

  2. Set the wake-up source: In sleep_wevent_config[], configure the wake-up source (UART0/UART1/UART2_BT/UART_LOG) and specify the CPU to be woken up (WAKEUP_KM4 or WAKEUP_KM0). Ensure the interrupt is registered on the CPU to be woken up.

  3. Select the clock source:

    1. XTAL: In ps_config[], set xtal_mode_in_sleep to XTAL_Normal and set keep_OSC4M_on to TRUE.

    2. OSC2M: In ps_config[], set keep_OSC4M_on to TRUE.

  4. Set the operating voltage: In ps_config[], set sleep_to_08V to TRUE.

  5. Enter sleep mode by releasing the wake lock on KM4 (PMU_OS needs to be released because it is acquired by default at system startup).

  6. Clear the UART/LOGUART interrupt after waking up.

Note

  • When using UART as a wake-up source, the following limitations apply:

  • The Rx clock source can only be OSC2M, and OSC4M must not be turned off during sleep. It is not recommended to use UART as a wake-up source when the baud rate is greater than 115200.

    • Before sleep, you need to call the API RCC_PeriphClockSource_UART(UARTx_DEV, UART_RX_CLK_OSC_LP) to switch the clock to OSC2M.

    • If higher baud rate is required after waking up, you can use the API RCC_PeriphClockSource_UART(UARTx_DEV, UART_RX_CLK_XTAL_40M) to switch to XTAL40M Rx clock.

  • Any part of commands used for wake-up that exceed the FIFO depth (64 bytes) will be lost.

  • When using LOGUART as a wake-up source, the following limitations apply:

  • If the Rx clock source is OSC2M, OSC4M must not be turned off during sleep.

    • Before sleep, you need to call the API RCC_PeriphClockSource_LOGUART(LOGUART_CLK_OSC_LP) to switch the clock to OSC2M.

    • If higher baud rate is required after waking up, you can use the API RCC_PeriphClockSource_LOGUART(LOGUART_CLK_XTAL_40M) to switch to XTAL40M Rx clock.

  • If the Rx clock source is XTAL40M, XTAL must not be turned off during sleep.

  • Any part of commands used for wake-up that exceed the FIFO depth (16 bytes) will be lost.