2019-07-03 03:23 PM
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:
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
Figure 2: Powering down from 3.3 V
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.
2019-07-03 04:32 PM
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
2019-07-03 05:18 PM
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.
2019-07-04 01:26 AM
Remove this capacitor.
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