0

i wanted to use 4Mb baud rate of stm32f103 usart. how can i check that data received in PC are correct? I used hyper terminal but in its setting there is no 4Mb baud rate and when i run my code i receive wrong characters.but in low baud rates like 115200b data received correctly.

Mahtab
  • 107
  • 3
  • 14
  • What would the normal usecase for this setup be, since a PC USART can't handle speeds like that. Are you connecting two such units together? – roelofs Aug 10 '14 at 08:47
  • i chose 921600b baudrate ,its the highest that hyper terminal has .yes I connected to unit together it worked with 115200b baudrate. – Mahtab Aug 10 '14 at 08:55
  • The fact that HT supports the baud rate, doesn't necessarily mean your PC hardware does. What happened when you connected at that baudrate to the PC? – roelofs Aug 10 '14 at 08:56
  • in addition when i set bauderate to 921600b in my code ,i received wrong characters yet.when I connected at that baudrate to the PC I received wrong characters. – Mahtab Aug 10 '14 at 08:58
  • 1
    It sounds like your PC hardware may not support it properly (or there are issues with cabling and stray capacitance...). – roelofs Aug 10 '14 at 08:58
  • what do you recommend? – Mahtab Aug 10 '14 at 09:00

2 Answers2

1

If the transmitter and receiver are not sending at the same speed, the receiver will erroneously read the data. Each byte has a start bit that synchronizes the receiver, and the remaining bits are determined by time.

Typical PC RS-232 serial ports only go up to 115200 bps. It is likely that your PC can't handle the 4 Mbps rate. I would recommend using 115200 or lower speed.

If you are communicating between devices and need higher speed, and just using the PC to debug, you could change the speed for debug purposes and set it faster once your comms are working. Alternatively, you could use a logic analyzer - This could be tedious to do manually, but some may have functions to read serial data.

mbmcavoy
  • 2,628
  • 5
  • 23
  • 34
  • I need PC to receive data and process it. So with due attention to what you said , i think using ethernet is better to communicate data with PC, do you? – Mahtab Aug 23 '14 at 07:49
  • Interesting thought. At a glance, it looks like the STM32F103 does not have ethernet, but the STM32F105/107 do. Ethernet however, would require UDP, TCP/IP, or similar protocols, and be MUCH more complex to implement on both ends. Also, you may have more security concerns if this is connected to a common network. USB will be more complex than a USART, but much less than ethernet, and should easily be able to handle the data rate. – mbmcavoy Aug 25 '14 at 15:39
0

If you have two of the stm32f19 modules, connect them using the USART at 4Mb, at then send a block of data with a checksum (or even a hardcoded block that you can compare). On the receiving unit, either confirm the checksum, or compare the data to see if the link works.

roelofs
  • 2,132
  • 20
  • 25