STM32F042K6 USART not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-10-18 6:48 PM
Solved! Go to Solution.
- Labels:
-
Bug-report
-
ST boards
-
STM32F0 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-10-19 3:06 PM
Its not clear how it determines how many of the 12 bytes were received or not, but as it ping-pongs between the two blocking functions, there some 12 character times where it's not going to be sufficiently responsive to in-coming data, and is going to lose it, or get overrun errors.
Up vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-10-19 3:12 PM
A byte can always be lost because of wiring issues, noise, delayed interrupts, CPU/DMA/bus overload etc.
This isn't new at all. All seasonal programmers should know how to recover from a missing/corrupt byte.
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
‎2023-10-19 4:01 PM
Thank you to all those who responded to the issue. There's nothing wrong with the program. The program simply waits until the UART Rx FIFO has 12 bytes of data. Then re-transmit the received data. There are two possible problems that might exist here. It's either the UART modules are faulty, or there are solder bridges to be configured. If you have an STM32F042K6, please test the program on your board to verify this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-10-19 5:07 PM
The point is that there is no "if" for this. It is always like that! There is no case of "known length messages". The only other way is called very simply - broken code. We should start calling things for what they really are...
It is not new for me and you, but almost none of the university/college students and other beginners, including ST's geniuses, know and understand this. That shows that the teachers and more experienced colleagues are also mostly incompetent. Honestly, the education system and the society in general still haven't grown up to understand that the software development is a discipline of engineering, not some bohemian art done by wizards.
By the way, the HAL_UARTEx_ReceiveToIdle_IT() is still half useless, because it cannot do a continuous reception. Read this post to see how ridiculous the HAL is and how simple a decent API can be.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-10-19 5:20 PM
You've mentioned solder bridges, so does that mean you have a Nucleo-F042K6?
You haven't mentioned what is connected to uart1 and uart2?
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
‎2023-10-19 5:30 PM
By default, cubeMX assigns USART2 Tx and Rx to PA2 and PA3. According to the STM32 manual, for virtual communication (USB), only PA2 and PA15 are used. I had to change PA3 to PA15. Now the program works.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-10-19 5:47 PM
When you start a new Nucleo-F042K6 board project it configures VCP correctly. You ended up creating a new project for just a STM32F042 which defaults to PA2 and PA3.
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
‎2023-10-19 9:54 PM
Mine always defaults to PA2 and PA3 when I create a new project.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-10-19 10:30 PM
I just explained that you need to start a new BOARD Project.
TimerCallback tutorial! | UART and DMA Idle tutorial!
If you find my solution useful, please click the Accept as Solution so others see the solution.

- « Previous
-
- 1
- 2
- Next »