STM32Cube  Version 2.0
Create Projects for STM32U5 Series with STM32Cube HAL and STM32CubeMX
 All Files Functions Variables Macros Pages
CMSIS-Driver UART Setup

The CMSIS-Driver USART requires:

  • Setup of USART/UART mode (Asynchronous, Synchronous, Single wire, IrDA or SmartCard)
  • Optional configuration of Hardware Flow Control (only in Asynchronous mode).

Valid settings for various evaluation boards are listed in the table below:

Peripheral Resource B-U585I-IOT02A (PMOD CN4)
USART Peripheral USART2
USART Mode Asynchronous
TX Pin PA2
RX Pin PA3

For different boards, refer to the hardware schematics to reflect correct setup values.

The STM32CubeMX configuration for B-U585I-IOT02A with steps for Pinout, Clock, and System Configuration are listed below. Enter the values that are marked bold.

Pinout view

  1. Configure USART2 pins
    • PA2: USART2_TX
    • PA3: USART2_RX

Pinout & Configuration tab

  1. Under Connectivity open USART2:
    • Section Mode
      • Mode: Asynchronous
      • Hardware Flow Control: Disable
    • Section Configuration
      • Parameter Settings: not used
      • User Constants: not used
      • NVIC Settings: configured later
      • DMA Settings: configured with GPDMA1
      • GPIO Settings: check used pins

  2. Under System Core open GPIO:
    • Group By Peripherals - USART:
      Pin Name Signal on Pin GPIO mode GPIO Pull-up/Pull..Maximum out..
      PA2 USART2_TX Alternate F..No pull-up and no..Very High
      PA3 USART2_RX Alternate F..No pull-up and no..Very High

  3. Under System Core open GPDMA1:
    • Section Mode
      • Channel 0: Standard Request Mode
      • Channel 1: Standard Request Mode
    • Section Configuration
      • CH0
        • Request Configuration - Request: USART2_TX
        • Channel configuration - Direction: Memory to Peripheral
        • Source Data Setting - Source Address Inc..: Enabled
        • Source Data Setting - Data Width: Byte
        • Destination Data Setting - Destination Address Inc..: Disabled
        • Destination Data Setting - Data Width: Byte
      • CH1
        • Request Configuration - Request: USART2_RX
        • Channel configuration - Direction: Peripheral to Memory
        • Source Data Setting - Source Address Inc..: Disabled
        • Source Data Setting - Data Width: Byte
        • Destination Data Setting - Destination Address Inc..: Enabled
        • Destination Data Setting - Data Width: Byte

  4. Under System Core open NVIC:
    • Section Configuration
      • NVIC
        NVIC Interrupt Table Enable Preemption Priority Sub Priority
        GPDMA1 Channel 0 global interrupt ON 0 0
        GPDMA1 Channel 1 global interrupt ON 0 0
        USART2 global interrupt ON 0 0

Clock Configuration tab

  1. Configure USART2 Clock.

Project Manager tab

  1. Open Advanced Settings:
    • enable Do Not Generate Function Call for MX_USART2_UART_Init.
Note
The CMSIS Driver:USART (API):USART component in the Manage Run-Time Environment dialog adds multiple C source files to the project. The interface selection in STM32CubeMX selects the actual implementation that is compiled: IrDA, SmartCard, UART, or USART.