Skip to main content
Graduate II
June 28, 2024
Solved

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

  • June 28, 2024
  • 3 replies
  • 1262 views

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. 

 

    This topic has been closed for replies.
    Best answer by jumman_JHINGA

    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.  

    3 replies

    Graduate II
    June 28, 2024

    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. 

    jumman_JHINGAAuthorAnswer
    Graduate II
    June 28, 2024

    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.  

    Super User
    June 28, 2024

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

    Could you share an example implementation?

     


    @jumman_JHINGA 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: