2025-07-11 7:02 AM - last edited on 2025-07-11 7:18 AM by Andrew Neil
Hello,
I am using nucleo board f446re to interface with a sensor over UART. sensor is able to send the response data frame over rx line to mcu as mcu sends uart frame.
This transaction or data transfer is visually verified using logic analyser.
Actual issue is stm 32 is not able to capture the response packet.
Could you please assist to fix it.
Sensor sends 3 byte response frame. 0x08-0x00-0x0A
But mcu reads it as 0x00-0x08-0x00
Let me know if you need more information.
if (HAL_UART_Transmit (dev->uartHandle, (const uint8_t *)&txReadBuff, sizeof (txReadBuff), 5)!=HAL_OK)
return HAL ERROR:
if (HAL_UART_Receive (dev->uartHandle, (uint8_t *) &ackBuff, sizeof(ackBuff), 5)!=HAL_OK)
return HAL ERROR
AckBuff is an array of 3 bytes / uint8_t type.
Edited to apply source code formatting - please see How to insert source code for future reference.
2025-07-11 7:12 AM
Please show the full code - or, preferably, a minimum but complete example which illustrates the problem.
Have you checked the UART error flags to see if any errors are occurring (Framing, etc) ?
It looks like your code is not ready when the sensor starts sending
Have you tested your code using a terminal - before adding the extra uncertainties of the sensor?
Does the sensor have a protocol with defined frame structure? If so, better to receive under interrupt and parse that structure rather than just wait for an arbitrary number of characters with no synchronisation...
2025-07-11 7:16 AM
This is actually happening while reading one particular register.samw function works fine for rad action on other