G491 HAL_UART_RECEIVE issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-08 9: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:
Even with the simplest code i can think of the result is still the same:
The UART only reads one byte and then stops, going into timeout before the time actually expires
I then tried testing the same code on a F401 nucleo board and another g491, and it only works
- Labels:
-
STM32G4 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-08 9: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:
A complex system designed from scratch never works and cannot be patched up to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-08 9: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 .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-08 9: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-08 9: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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-08 10:02 AM
Maybe your HAL timebase is wrong or not working?
Does HAL_Delay() work correctly?
A complex system designed from scratch never works and cannot be patched up to make it work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-08 10:22 AM
I tried, HAL_Delay() works correctly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-08 12:01 PM
Attach your project and a drawing of how you connect both boards to which connector and pins
TimerCallback tutorial! | UART and DMA Idle tutorial!
If you find my solution useful, please click the Accept as Solution so others see the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-05-09 6: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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎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.
TimerCallback tutorial! | UART and DMA Idle tutorial!
If you find my solution useful, please click the Accept as Solution so others see the solution.
