UART signal is "rounded"

Check that the GPIO pin for UART TX is configured for alternative output push pull mode. It looks like it is configured for alternative output open drain.


Do you have a schematic for your circuit?

In addition to the misconfigured GPIO pin, another possibility is that you have a capacitor on your UART line, acting as a low-pass filter, and preventing the signal from rising quickly.


As mentioned above, setting it to output push-pull mode will solve the problem, however you may also want to check the "Maximum output speed" is set to 'very high', and if your system tolerates it, add the internal pull-up resistors; I know there's various schools of thought on whether USART should have pullups or not, so try it and see if it does what you want/need/project allows.

If you're using STM32CubeMX for your initialization/configurations, then these settings are all found in the pinout & configuration > USARTx (or UARTx, whichever channel you're using for your project) > GPIO Settings.

If you're just modifying the template file by hand (and presuming you're using the HAL libraries) then the pin settings should be in the src folder of your project, in the file called stm32F4xx_HAL_MSP.c (or whatever chip you're using)

You're looking for these lines;

GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);

Make sure the GPIO.InitStruct.Speet is set to very high (as above) and set InitStruct.Pull to: GPIO_InitStruct.Pull = GPIO_PULLUP;

I've managed to completely abuse the UART on an STM32F4 and get it running at 15MB/s without losing bits, which was the fastest speed my FTDI to USB converter would operate at. I see though in the CubeMX settings, it says to keep it below 1MB/s.

Tags:

Stm32

Uart

Serial