Serial Communications giving strange data

Hello,

I’ve been using the arduino for quite a while now, but I’ve come across something I’ve never seen before.

My serial communication is apparently broken. I can upload sketches, but the serial monitor just isn’t working. To make things simple, I’ll use a modified version of the SerialCallResponse example. The board send me the character ‘A’ until I send some serial input, then it spits out the string “This isn’t working”. Simple, ya?

the result? This is copy-pasted from the serial monitor.

ðððððððððððððððøðøüðøøðððððð (this is where I give it input) À¦??ç?µåæEóÀ¦??ç?ååæEûÀ¦Ä
ç?å?æEóÀ¦??ç?ååæEû?¦Ä?¿?åå¬Eó?¦Ä?·?åå¦EóÀ¦Ä
ç?å?æEóÀS??ç ååæEóÀ¦Ä?çååæEùÀÆÄ?çååæEóÀ¦Äç?åå®EóÀ¦??ç?ååæEøÀÞÄ?çååæEûÀ¦Äç?ååæEóÀÜÄ?çååæEø¦Ä?ç?ååæEóÀ¦??ç?¥åæEóÀ¦??ç?¿åæEûÀ¦Ä
ç?å?æEóÀ¦Ä?½?åå®EóÀÞÄ?çååæEøÀ¦Äç?ååæEóÀ¦Ä?çååæEóÀ¦Äç?å?æEóÀ¦Äç?ååæEó?¦Ä?¿?åå®EóÀ¦Äç?å?æEóÀ¦Ä?çååæóÀ¦Äç?ååæEóÀ¦Ä?çååæ%óÀ¦??ç?µåæEó?¦Ä?§?ååæ=óÀ¦Ä?ç?å?æEóÀ¦Äç?åæEóÀ¦Äç?åå¬EóÀæÄ?ç?ååæEøÀ¦Äç?å¥æEóÀ¦Ä

obviously not what you would expect. The output isn’t even consistent, though it does change when it is supposed to. I’ve checked baud rates and done all the normal troubleshooting, plus both the code and the physical arduino work on other computers; it seems like there is something wrong with my computer’s serial communication. Any ideas?

here’s the code if you’re interested:

void setup()
{
  Serial.begin(19200);
  establishContact();  // send a byte to establish contact until receiver responds 
}

void loop()
{
  if (Serial.available() > 0) {
    Serial.println("This isn't working");
    delay(300);
  }
}

void establishContact() {
  while (Serial.available() <= 0) {
    Serial.print('A', BYTE);   // send a capital A   
    delay(300);
  }
}

Ciao.

Try your serial term at 28800 or 38400 Baud. see if it comes out clean. Leave your sketch Baud the same.

Do you have the correct FTDI drivers? What arduino do you have? B/c if you have the Uno you shouldn't need them. That output seems familiar... usually what I get w/ incorrect baud rates...

Try this [u]very[/u] simple sketch:

void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println("A");
delay(100);
}

Can you paste the output? It should be consistent. (i.e. not necessarily "A A A A A" but " � � � �"

baum

Baum,

I tried as you suggested and got:

A A A A A A.......

But, only at 19200 terminal baud while sketch baud is 9600. I am working with 328 Pro Minis via USB-FTDI adapters.

19200/9600=2

Try multiplying programmed baud rate by 2.

Yes. That is correct. But, it should not be needed.

Is it an FTDI driver issue? Have you had this problem before?

It works fine on my Mega 1280. But, it has its onboard FTDI chip.

I only have this issue with incorrect baud rate. If you want, you could find the serial communication source file and edit it to multiply by two.

I see. Well, perhaps it is just a livable annoyance. As long as I remember to run the term 2X faster than the program.

Thx Baum.

No… That’s not what I meant. If your feeling adventurous, you can modify the source code to divide baud rates by two.

Here’s how:

  1. Download a new copy of the arduino environment just in case you break it.
  2. Navigate inside the arduino program. On a mac, control/right-click on the application and choose “Show Package Contents.” Sorry, have no idea how to do it on Windows and Linux, though this is how you would install a new library.
  3. For macs, navigate to Contents>Resources>Java>hardware>arduino>cores>arduino and open HardwareSerial.cpp with your favorite plaintext editor. :slight_smile:
  4. Windows and Linux paths should be similar, hope you find it. :slight_smile:
  5. Look for this
void HardwareSerial::begin(long baud)
{
  uint16_t baud_setting;
  bool use_u2x = true;

#if F_CPU == 16000000UL
  // hardcoded exception for compatibility with the bootloader shipped
  // with the Duemilanove and previous boards and the firmware on the 8U2
  // on the Uno and Mega 2560.
  if (baud == 57600) {
    use_u2x = false;
  }
#endif
  
  if (use_u2x) {
    *_ucsra = 1 << _u2x;
    baud_setting = (F_CPU / 4 / baud - 1) / 2;
  } else {
    *_ucsra = 0;
    baud_setting = (F_CPU / 8 / baud - 1) / 2;
  }

  // assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register)
  *_ubrrh = baud_setting >> 8;
  *_ubrrl = baud_setting;

  sbi(*_ucsrb, _rxen);
  sbi(*_ucsrb, _txen);
  sbi(*_ucsrb, _rxcie);
}
  1. Add
baud /= 2;

right after the function opening. Now you should have

void HardwareSerial::begin(long baud)
{
  baud /= 2;
  uint16_t baud_setting;
  bool use_u2x = true;

#if F_CPU == 16000000UL
  // hardcoded exception for compatibility with the bootloader shipped
  // with the Duemilanove and previous boards and the firmware on the 8U2
  // on the Uno and Mega 2560.
  if (baud == 57600) {
    use_u2x = false;
  }
#endif
  
  if (use_u2x) {
    *_ucsra = 1 << _u2x;
    baud_setting = (F_CPU / 4 / baud - 1) / 2;
  } else {
    *_ucsra = 0;
    baud_setting = (F_CPU / 8 / baud - 1) / 2;
  }

  // assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register)
  *_ubrrh = baud_setting >> 8;
  *_ubrrl = baud_setting;

  sbi(*_ucsrb, _rxen);
  sbi(*_ucsrb, _txen);
  sbi(*_ucsrb, _rxcie);
}
  1. Save and exit. Open arduino environment and load a simple serial sketch. See if it works. The idea is that the source code, if it sees, for example, 9600 baud, it will divide by 2 to get 4800 baud. With the Serial Monitor @ 9600, you should be good.

And yes, in a previous post, I made a mistake about dividing and multiplying.

  1. If this works, do the same in your orignal arduino, erasing the test one.

Good Luck!

OP here again. It's definitely not a baud rate issue. I've tried all the different rates with each other, and the output isn't even consistently the same for most of it. The problem has to be something deeper.

It occurred to me that it may be an issue with another type of microcontroller. I have a maple board too (and ARM processor based board from leaflabs). It's IDE is a modified version of the ArduinoIDE v18. It takes a different serial usb driver to communicate with that board, so that may have replaced the aurdino one.

Any idea how to reinstall the drivers needed for serial communication?

Arduino FTDI drivers come with software download.

Good Luck!

P.S. Very sorry pseudonymed. All this time, I though Utoto had originally asked the question, and was addressing his issue [which is now fixed]. Your issue, though, is prob. caused by the other MCUs. If you download the arduino software, drivers come with it.

Also, Utoto, how is the source code mode coming?

@pseudonymed:

Do you have anything connected to pin 0 or pin 1?

@Coding Badly

If he did, he would have trouble uploading.

@Coding Badly,

nope, the board has nothing on it. I can guarantee that the outgoing communication works too. It will communicate with other arduino boards and other computers, just not my main one. It's likely a problem with drivers, and I'll have to mess with that a bit before anything else.

@baum

Not great. If I were still in XP, I'd probably be good. But, I'm now in Ubuntu 10.04 and how to do certain thing is still mystery. I did look for the correct folder and file, but, couldn't find it.

Is there an option somewhere to view the contents of the application?