Skip to main content
David Pekin
Senior
January 10, 2018
Question

stm32f722ZE Nucleo UART sample code problem

  • January 10, 2018
  • 7 replies
  • 2100 views
Posted on January 10, 2018 at 21:56

Hello, 

I've just built the UART sample code for the 722ze Nucleo board and have a problem. I have not modified the code (except for the transmitted character buffer).  The sample code shows setting up the unit for a 9600 N81 format.  The character buffer that is transmitted is 153 characters long.  When I transmit from the Nucleo I receive the correct number of characters on the RealTerm serial capture program but it's gibberish.  None of the ASCII characters are discernable and I can't make heads or tails of how the bits might be shifted...  For example, I am sending '12345' which in hex is 0x31 0x32 0x33 0x34 0x35  and I receive 0xEB 0x9B 0x99 0x97 0x95.  

Has anyone seen anything like this? 

    This topic has been closed for replies.

    7 replies

    Tesla DeLorean
    Guru
    January 10, 2018
    Posted on January 10, 2018 at 22:33

    Over the VCP, or RS232?

    RS232 is at different levels and inverted wrt CMOS levels from STM32 USART

    Make sure PLL and HSE_VALUE reflect the 8 MHz clock, not 25 MHz

    If in doubt output 'U' (0x55) in a stream, and scope the signals.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    David Pekin
    Senior
    January 11, 2018
    Posted on January 11, 2018 at 00:37

    Ahh...  That might be the issue. I've attached the RS232 serial TX & RX directly to the PC6 and PC7 I think.  So I need a serial driver chip between PC6&7 I assume?

    Tesla DeLorean
    Guru
    January 11, 2018
    Posted on January 11, 2018 at 00:58

    MAX3232 type chip, lots of translation boards on eBay, if you need to get to RS232 levels

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    T J
    Senior III
    January 10, 2018
    Posted on January 10, 2018 at 22:37

    maybe you have a grounding problem, did you check the baud rate on the scope ?

    same number of chars ? maybe you are not reading the correct buffer ?

    David Pekin
    Senior
    January 11, 2018
    Posted on January 11, 2018 at 00:38

     ,

     ,

    Thanks. , I'm getting the correct ♯ of characters. ,  ,I think I need a serial driver chip between the GPIO pins and the RS232 pins I guess.

    T J
    Senior III
    January 11, 2018
    Posted on January 11, 2018 at 01:14

    You wont be getting inverted data because the start bit is randomly being set within the data bit stream, lucky to receive the correct number of bytes.

    but I think that inside the STM processor, some parts will be evaporating as we speak..

    best not to connect it directly like that.

    did you try to invert the data input pin ? it is a function of this usart. not sure how to use it, but your data will look right for a minute or two.

    The processor will not last long, or maybe only the serial receive port will become disconnected internally.

    ranran
    Senior
    December 12, 2018

    Hi,

    I have the same issue.

    Is there a way to do this "voltage conversion" in software using UART hal driver?

    Thanks

    Tesla DeLorean
    Guru
    December 12, 2018

    It is an electronics/signals issue, it can't be fudged in software.

    RS232 signal levels have clearly defined expectations, the STM32 pin interface doesn't meet those.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    ranran
    Senior
    December 12, 2018

    I understand.

    We nee to have serial console.

    It means that there is no option for a serial console using nucleo board, unless we use a signal converted chip . Thanks,

    Tesla DeLorean
    Guru
    December 12, 2018

    >>I understand

    Not sure you do, you seem confused.

    The NUCLEO-H743ZI has a USART connected to the VCP provide by the ST-LINK, you can send data to the USART on the H7 side and get the data on a PC side terminal application.

    You can also connect a SiLabs CP2102 type USB-to-CMOS Serial dongle to any of the other available USART on the board.

    You can also use the Serial Wire Viewer (SWV SWO/PB3) as a debug terminal.

    0690X000006CoZ4QAK.jpg

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    ranran
    Senior
    December 12, 2018

    Hi Clive,

    You right. I just got a board today, so I am a bit too much enthusiastic..

    I managed to see printf using the SWV.

    But I don't understand the 1st option you've mentioned:

    "The NUCLEO-H743ZI has a USART connected to the VCP provide by the ST-LINK"

    How do I use this UART, which UART number is it ? Is there an example showing how to use it (actually I tried all examples).

    Thanks!

    ran

    Tesla DeLorean
    Guru
    December 12, 2018

    The User Manual and Schematic indicate it is USART3 on PD8/PD9

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    ranran
    Senior
    December 13, 2018

    It does work with USART3, just what I needed ! Thanks a lot

    ranran
    Senior
    December 12, 2018

    Right, I wonder why there was no example using this USART3...

    I shall try it. Thanks !