cancel
Showing results for 
Search instead for 
Did you mean: 

Can't communicate with another device via UART

jagauthier
Associate III

I've been fighting this problem for some time. I have a simple custom made board based on STM32G05. I'm utilizing 2 UARTs. One of them I use just for serial port debug. Takes keyboard input (but don't use it) and print out data for debugging.

The other one connects to a different MCPU. An ESP32, specifically ESP32-CAM.

As the ESP32-CAM boots, it sends some diagnostics to the serial port.

My STM32 does not see this data.

I can use a USB serial port (with putty) and communicate to both STM32 and ESP32 independently. However, connecting the ESP32 TX pin to STM32 RX pin does not give me any data at all.

I can "tap into" the ESP32 TX pin and connect this to a USB serial port RX pin and see the data while it boots, but the STM32 simply does not see it. I've look at the data on the scope, and logic levels are correct.

0693W00000NrxZcQAJ.jpg 

My code is straight forward

#include "main.h"
 
extern UART_HandleTypeDef huart1;
extern UART_HandleTypeDef huart2;
 
uint8_t rx[6];
uint8_t rx2[6];
 
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
	if (huart->Instance == USART1) {
		serprintf("UA1: %c\n\r", rx[0]);
		HAL_UART_Receive_IT(&huart1, rx, 1);
	}
	else {
		serprintf("UA2: %c\n\r", rx2[0]);
		HAL_UART_Receive_IT(&huart2, rx2, 1);
	}
    if (rx[0] == 13)  {
        serprintf("\n\r");
    }
}
 
void app_main(void)
{
    HAL_StatusTypeDef status;
    serprintf("Starting...\n\r");
    HAL_UART_Receive_IT(&huart2, rx, 1);
    HAL_UART_Receive_IT(&huart1, rx2, 1);
    while (1) {
	}
   }

I've tried this using both serial ports and the behavior follows both.

However, the STM32 is able to send data successfully to the ESP32CAM. It just can't seem to receive it.

1 ACCEPTED SOLUTION

Accepted Solutions
jagauthier
Associate III

I solved this. The issue is that performing a UART write (serprintf) inside the interrupt was detrimental to performance and the interrupt wasn't actually getting the data.

View solution in original post

1 REPLY 1
jagauthier
Associate III

I solved this. The issue is that performing a UART write (serprintf) inside the interrupt was detrimental to performance and the interrupt wasn't actually getting the data.