For an STM32L476RG I use UART1/DMA1 almost like it is done in STM32Cube_FW_L4_V1.7.0/Projects/STM32L476RG-Nucleo/Examples_LL/USART/USART_Communication_TxRx_DMA/Src/main.c. The initialization of the GPIOs looks like:
LL_GPIO_SetPinMode (GPIOA, LL_GPIO_PIN_9, LL_GPIO_MODE_ALTERNATE);
LL_GPIO_SetAFPin_8_15 (GPIOA, LL_GPIO_PIN_9, LL_GPIO_AF_7);
LL_GPIO_SetPinSpeed (GPIOA, LL_GPIO_PIN_9, LL_GPIO_SPEED_FREQ_VERY_HIGH);
LL_GPIO_SetPinOutputType (GPIOA, LL_GPIO_PIN_9, LL_GPIO_OUTPUT_PUSHPULL);
LL_GPIO_SetPinPull (GPIOA, LL_GPIO_PIN_9, LL_GPIO_PULL_UP);
LL_GPIO_SetPinMode (GPIOA, LL_GPIO_PIN_10, LL_GPIO_MODE_ALTERNATE);
LL_GPIO_SetAFPin_8_15 (GPIOA, LL_GPIO_PIN_10, LL_GPIO_AF_7);
LL_GPIO_SetPinSpeed (GPIOA, LL_GPIO_PIN_10, LL_GPIO_SPEED_FREQ_VERY_HIGH);
LL_GPIO_SetPinOutputType (GPIOA, LL_GPIO_PIN_10, LL_GPIO_OUTPUT_PUSHPULL);
LL_GPIO_SetPinPull (GPIOA, LL_GPIO_PIN_10, LL_GPIO_PULL_UP);
The problem is with the second LL_GPIO_SetPinMode() which is surrounded by two pairs of do_mark() invocations. do_mark() toggles a GPIO pin so that I can get a relation between the code and the related signals. The attached screen shot shows the signal of PA9 (yellow) and the test signal as generated by do_mark(). Note that PA9 is USART1_TX and not USART1_TX.Unfortunately, the receiver interprets the pulse as a start bit. It’s a bit short (36 µs). A bit cell is 52 µs wide (19200 Baud).
- How can I avoid the pulse? I have already played around with a preliminary initialization as a GPIO-controlled output and set the pin with no avail.
- Side question: The example code initializes USART1_RX (= PA10) with LL_GPIO_OUTPUT_PUSHPULL and LL_GPIO_PULL_UP. Isn’t the mode of the port completely controlled by the USART so that these settings are ignored?