cancel
Showing results for 
Search instead for 
Did you mean: 

How to verify baudrate is configured correctly or not by implementing self test code for UART?

JJhin.1
Senior II

Hello guys!

 we generally configures UART in the cube mx and generating the codes, and after by calling Transmit and Recieve functions we are checking the outs on serial terminals.. if we dont get desired outputs then we are trying to dubbug and testing the hardware and observing the frames on CROs.

For most of the software engineers operating CROs is a headache. thats why i was thinking to build Selt test code in that it should verify the UART initialization is configured properly or not as well as it should check the configured baudrate is generating correctly or not by getting feedback on some other GPIOs. 

 

1 ACCEPTED SOLUTION

Accepted Solutions
JJhin.1
Senior II

by goin through with This document usart-automatic-baud-rater-detection i implemented test code for testing baudrate is getting generated properly or not.. here im taking feedback from TX pin at another EXTI pin. and transmitting 0x7F through UART. after compareing Rising Edges im able to know wheather UART configuration is done properly or not. if not done properly im generating Warning signals using User LED.  

View solution in original post

3 REPLIES 3

Define "configured properly". You can just read UART registers and compare them with predefined (proper) values. But of course this method can't cover situation when you have wrong clock configuration and situation when you have wrong source clock frequency and situation when you have wrong GPIO configuration and many others. You should specify what exactly you want to check. 

JJhin.1
Senior II

by goin through with This document usart-automatic-baud-rater-detection i implemented test code for testing baudrate is getting generated properly or not.. here im taking feedback from TX pin at another EXTI pin. and transmitting 0x7F through UART. after compareing Rising Edges im able to know wheather UART configuration is done properly or not. if not done properly im generating Warning signals using User LED.  

Andrew Neil
Evangelist III

Thanks for sharing the idea - it is a common problem!

Could you share an example implementation?

 


@JJhin.1 wrote:

For most of the software engineers operating CROs is a headache.  


I'd have thought that should be a required skill for anyone writing microcontroller code ?

That's a key thing  which distinguishes microcontroller software developers from run-of-the-mill programmers!

:beaming_face_with_smiling_eyes: