2024-05-08 09:00 AM
I am developing a project in which I need to read data that is sent on the UART.
Since it was not working i tried to write a new firmware that only reads from UART, with the following code:
2024-05-08 09:24 AM
@massimoGiacobbe wrote:going into timeout before the time actually expires
How do you determine that?
What is sending the data?
Please use this button to properly post source code:
2024-05-08 09:49 AM
Hello,
while (1)
{
huart3RxStat=HAL_UART_Receive(&huart2,PWR_Received_data, 10, 1000); //for debug
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
This is something asynchronous vs sending data. How do you send data? You can lose data if you're not starting the reception before sending data by the sender .
2024-05-08 09:55 AM
Sorry, i misclicked on accept as a solution and don't know how to revert.
The data is being sent from another board at 200 Hz, 10bytes per packet.
When i wrote this code on the F401 nucleo it was received with no problem, while i tried on 2 different g491 and it didn't work on wither board. I checked the signal integrity with an oscilloscope both at the input pin at the board and right before the mcu's pin and it was ok.
What happens is that it only updates the first byte of the buffer and then goes into timeout
2024-05-08 09:58 AM
Thanks for the info about the code, I'll use it in the future.
The data is being sent from another board at 200 Hz, 10bytes per packet.
When i wrote this code on the F401 nucleo it was received with no problem, while i tried on 2 different g491 and it didn't work on wither board. I checked the signal integrity with an oscilloscope both at the input pin at the board and right before the mcu's pin and it was ok.
Regarding the timeout, i tried putting in 10000 as timeout value (i saw it being suggested in another post), but when i execute with the debugger it instantly returns Hal_timeout as status.
When i tried to receive the data using HAL_UART_Receive_IT the status it returned was always HAL_BUSY, but otherwise the issue was the same
2024-05-08 10:02 AM
Maybe your HAL timebase is wrong or not working?
Does HAL_Delay() work correctly?
2024-05-08 10:22 AM
I tried, HAL_Delay() works correctly
2024-05-08 12:01 PM
Attach your project and a drawing of how you connect both boards to which connector and pins
2024-05-09 06:20 AM
I have attached the ioc and the main (the only code i've written that wasn't generated by cubeMX is the code i wrote in the post).
The data is being sent by another board and i have already checked the signal integrity with an oscilloscope.
Again, the problem is specific to the G491 mcu, i have tried 2 different firmwares on 2 different g491 and it doesn't work on either, I have tried to do the same thing on a F401 and it works, so the signal and the connections are not the problem.
2024-05-09 12:50 PM
Curious on why you're using UART2 which is the VCP? Show a diagram on how your two boards are connected.