Serial.read baud-rate issues...

Bullwinkle

  • Full Member
  • ***
    • Posts: 14
    • View Profile
I've been using a TinyDuino setup successfully for quite a while now, with the Arduino Console set to 115200 baud.
I have had NO problems with OUTput spewing lots of data, with no garbled characters.  I recently decided to add code to accept a user (Console Serial) input ("serial number") to be written to EEPROM.  After wasting far too much time trying to figure out why i was reading back GARBAGE from the EEPROM after (supposedly) writing it, I backtracked to the simple loop using Serial.read(), where I built the user-supplied S/N string.   It was GARBAGE.  After lots of Google finger exercises, I found that some people apparently had (output-related) problems with higher baud-rates; but not much discussion of INput scenarios.  But I decided to try knocking my port speed down to 9600 just for giggles. VOILA!  It works with no problems. HA.
I'm writing this a) to inform others who might go down this path, and b) to pose the question: "is this a possible Hardware issue, or a Arduino/Library Software issue?"


lennevia

  • Administrator
  • Hero Member
  • *****
    • Posts: 437
    • View Profile
To answer your question, it's possible both hardware and software can cause garbage printing issues. The common software issue, as you saw, is the mismatch of baud rates between two communicating devices. The different rates of communication essentially become foreign languages as the data is receiving and transmitting independently and there is chaos, which gives us garbage.
A common hardware issue can occur when trying to communicate with more than two serial devices on one serial bus. When two devices communicate back and forth on one line, there is some order. When there are multiple devices communicating on one line, there is chaos, all devices could be speaking at once or none at all, again producing visual garbage on the Serial Monitor.


Bullwinkle

  • Full Member
  • ***
    • Posts: 14
    • View Profile
Well, perhaps I wasn't clear when I said "knocking my port speed down to 9600...": I should have said "I changed both the port speed AND the baud-rate specified in the code" from 115200 to 9600.  There was No mismatch at any time.
As for conflicts, there are none.  Also, I'm not using a hub or intermediate USB connection; I suspect a hardware issue of some sort, but don't have time to worry about it at this point.  Still, would be nice to understand what's going on.


Ben Rose

  • Administrator
  • Hero Member
  • *****
    • Posts: 392
    • View Profile
Just saw this one- For future reference, this is effectively a hardware limitation for the processor. The 8MHz ATmega(any that I've used) have a significant error in the baud rate generation when trying to do 115200. Why does it work one way? The FTDI chipset is 'smarter' and allows for receiving the significant error, but does not apply it back to what it sends to the TinyDuino.

There's another thread referencing the Arduino WiFi firmware updater tool not working. Same issue. I was able to modify the tool to run at 250K baud- much faster, but a rate that the 8MHz processor can generate exactly, so it works fine.

Unfortunately a lot of our older example code used 115200 since it was output only and worked fine. I'm switching things to 9600 as they need updates(when I remember!).


Bullwinkle

  • Full Member
  • ***
    • Posts: 14
    • View Profile
Ben,
  Thanks for the confirmation!  (I hadn't been back to this in quite a while, either! :)
I appreciate the follow-up!
Jim
Happy New Year!!!


 

SMF spam blocked by CleanTalk