cancel
Showing results for 
Search instead for 
Did you mean: 

USART1 TX troubles on STM32F407

Player 1
Associate

I have an STM32F07IGH6U MCU on an STM3240G-EVAL board, and I'm trying to achieve serial communication with my PC. Receiving works fine, but transmitting is failing in weird ways. I'm quite new to the world of microcontrollers, so please pardon my ignorance.

Here's my setup:

  • USART1 parameters:
    • 115200 baudrate
    • 8 bits word length
    • No parity
    • 1 stop bit
  • PA9 (USART1_TX) and PA10 (USART1_RX) connected to a Sparkfun FTDI Basic board.
    • Grounds are connected.
    • Resistors R21 and R18 have been removed from the board, per the user guide.
  • FTDI Basic board connected to USB 2.0 port on my PC. Monitored in RealTerm.
  • Code generated with STM32CubeMX.
  • Debugging via CN21 in System Workbench.

All my code is doing is transmitting a continuous stream of "U" characters, which I would expect to produce a square wave with a frequency equal to half the baudrate and an amplitude of 3.3 V. That's exactly what it looks like on the RX line when I send U's via RealTerm and probe between the MCU and the FTDI Basic. But when I probe the TX line, it shows a DC offset of about 2.20 V and an amplitude of about 0.24 V (Figure 1). Why?

I tried another test, disconnecting the FTDI Basic from the MCU. When MX_USART1_UART_Init() runs and initializes the internal pull-up resistor on PA9, the voltage jumps to 3.3 V relatively fast. But when I disconnect power from the board after this occurs and before main() runs, the voltage on PA9 gradually drops toward zero, as if there were a capacitor on PA9 (Figure 2). Repeating with the FTDI Basic results in the same effect, but with a DC offset of about 1 V.

main() function

int main(void)
{
  /* USER CODE BEGIN 1 */
 
  /* USER CODE END 1 */
  
 
  /* MCU Configuration--------------------------------------------------------*/
 
  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();
 
  /* USER CODE BEGIN Init */
 
  /* USER CODE END Init */
 
  /* Configure the system clock */
  SystemClock_Config();
 
  /* USER CODE BEGIN SysInit */
 
  /* USER CODE END SysInit */
 
  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_DMA_Init();
  MX_USART1_UART_Init();
  MX_IWDG_Init();
  /* USER CODE BEGIN 2 */
  /* USER CODE END 2 */
 
  /* Infinite loop */
  /* USER CODE BEGIN WHILE */
  while (1)
  {
    /* USER CODE END WHILE */
 
    /* USER CODE BEGIN 3 */
    uint8_t Test = 0x55; // U == 0101 0101
    HAL_UART_Transmit_IT(&huart1, &Test, sizeof(Test));
  }
  /* USER CODE END 3 */
}

Blue is PA9 and yellow is PA10.

Figure 1: Transmitting "U" stream

0690X000009YO2eQAG.bmp

Figure 2: Powering down from 3.3 V

0690X000009YO2jQAG.bmp

Where is this apparent capacitance coming from? Is the pin fried? Do I have no idea what I'm doing? Any assistance would be greatly appreciated.

3 REPLIES 3

Perhaps review the schematic? Doesn't PA9 conflict with VBUS? And have 5V driven on it? Perhaps drive PH5 low https://www.st.com/content/ccc/resource/technical/document/user_manual/25/21/69/1d/13/c5/4e/c9/DM00036746.pdf/files/DM00036746.pdf/jcr:content/translations/en.DM00036746.pdf

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

In my setup I followed Table 20 of the eval board's user guide (UM1461), which says to "Remove USB cable from CN8" and "Remove R18" in order to disconnect from VBUS_FS.

I neglected to mention that in a separate test, I initialized PA9 as a regular GPIO output pin, with and without a pull-up, and it did not appear to exhibit that kind of exponential decay when turned on and off; it just went straight up to 3.3 V and straight down to 0.

Remove this capacitor.0690X000009YOklQAG.png

This is a known problem, the same is on the 'F4 DISCO, and we've discussed it here since maybe 2013 or so, so I'd expect it to be already part of the manual...

JW