UART reading problem
Hello,
I have STM32WLE5CBU6 and I communicate with my Quectel chip over standard UART communication (interface LPUART, PA2, PA3) via AT commands.
Transmitting from STM to Quectel is always working well, but when I want to read response from Quectel chip, it in most cases does not work. Strange thing is that it sometimes after startup works (< 1 % of cases), however I do not have an idea why it sometimes works and sometimes does not.
The behavior is the same all the time from power on:
- When it receives correctly first AT response, it receives correctly any other response.
- When it does not receive correctly first AT response, it does not receive correctly any other response.
Sometimes it is ok the whole day, but when I try it again after a day, it stops working.
I have tried:
- Changing domain voltage on Quectel chip (3,3 V and 1.8 V)
- Connecting oscilloscope to RX of STM - voltage levels seems to be ok
- Connecting CH340 in parallel - CH340 reads correctly all responses from Quectel chip and STM does not
Anybody knows, how to solve it?
Hardware connection:
- No pull ups
- 2.2 k resistor between STM and Quectel (CH340 and oscilloscope were measuring after resistor as well as STM is)
I am sending and receiving data with these commands:
const uint8_t AT_Tx[] = "AT\r";
uint8_t AT_Rx[16];
HAL_UART_Transmit_IT(&hlpuart1, AT_Tx, sizeof(AT_Tx));
HAL_UART_Receive(&hlpuart1, AT_Rx, sizeof(AT_Rx), 300);This is my setup of hlpuart1:
hlpuart1.Instance = LPUART1;
hlpuart1.Init.BaudRate = 115200;
hlpuart1.Init.WordLength = UART_WORDLENGTH_8B;
hlpuart1.Init.StopBits = UART_STOPBITS_1;
hlpuart1.Init.Parity = UART_PARITY_NONE;
hlpuart1.Init.Mode = UART_MODE_TX_RX;
hlpuart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
hlpuart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
hlpuart1.Init.ClockPrescaler = UART_PRESCALER_DIV1;
hlpuart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
hlpuart1.FifoMode = UART_FIFOMODE_DISABLE;
if (HAL_UART_Init(&hlpuart1) != HAL_OK) {Error_Handler();}
if (HAL_UARTEx_SetTxFifoThreshold(&hlpuart1, UART_TXFIFO_THRESHOLD_1_8) != HAL_OK) {Error_Handler();}
if (HAL_UARTEx_SetRxFifoThreshold(&hlpuart1, UART_RXFIFO_THRESHOLD_1_8) != HAL_OK){Error_Handler();}
if (HAL_UARTEx_DisableFifoMode(&hlpuart1) != HAL_OK) {Error_Handler();}In CubeMX:
- NVIC interrupt is checked

