Go Down

Topic: Baud rate problem (Read 88 times) previous topic - next topic

DarkoJ

May 13, 2015, 10:43 pm Last Edit: May 13, 2015, 11:34 pm by DarkoJ
Hi all,

I'm programming the Arduino Uno Board (ATMEGA328P µC) in Atmel Studio 6.0.
Compiling and then uploading it on the µC works, but only with a predefined BAUD RATE of 115200.
Under Tool > External Tools - there's following defined:
Title:             Usb to Serial Programmer: COM9
Command:     C:\Arduino\bin\avrdude.exe
Arguments:    -C C:\Arduino\etc\avrdude.conf -v -v -p atmega328p -c arduino -P\\.\COM9 -b 115200 -D -U flash:w:"$(ProjectDir)Debug\$(ItemFileName).hex":i

After changing the baud rate to 9600 or 38400, uploading the code fails with the following message:

------------------------------
avrdude.exe: Version 5.11, compiled on Sep  2 2011 at 19:38:36
             Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
             Copyright (c) 2007-2009 Joerg Wunsch

             System wide configuration file is
"C:\Arduino\etc\avrdude.conf"

             Using Port                    : \\.\COM9
             Using Programmer              : arduino
             Overriding Baud Rate          : 38400
avrdude.exe: stk500_getsync(): not in sync: resp=0x00

avrdude.exe done.  Thank you.
------------------------------


Can someone please tell me, what to do? I need a baud rate of 38400. If I use 115200, I don't really get the symbols I want

PS: If i compile the code in the Arduino IDE and upload it on the microcontroller, it works! The terminal shows what I sent from another device using bluetooth

Thanks,
D.

HugoPT

#1
May 14, 2015, 10:14 am Last Edit: May 14, 2015, 10:17 am by HugoPT
Quote
Arguments:    -C C:\Arduino\etc\avrdude.conf -v -v -p atmega328p -c arduino -P\\.\COM9 -b 115200 -D -U flash:w:"$(ProjectDir)Debug\$(ItemFileName).hex":i
This 115200 is the speed that you computer will upload your code to your microcontroller.That speed should be "hard coded" inside of the bootloader, so if you change it when you want upload the program your micro still be waiting to receive the program @ 115200 bps.
So you design you code to set the speed of UART to 38400, add your logic to your code and upload it with those 115200.After it upload, your code will start running and you UART will be running at 38400 like you have set in your code.
Resuming don't change Under Tool > External Tools the baudrate.Keep it as is. This is just the baud at upload speed!
Debian,Mint,Ubuntu
Arduino Mega 2560
Arduino Nano
Arduino Duemilanove
MAC OS Montain Lion
Raspberry PI Model B

DarkoJ

This 115200 is the speed that you computer will upload your code to your microcontroller.That speed should be "hard coded" inside of the bootloader, so if you change it when you want upload the program your micro still be waiting to receive the program @ 115200 bps.
So you design you code to set the speed of UART to 38400, add your logic to your code and upload it with those 115200.After it upload, your code will start running and you UART will be running at 38400 like you have set in your code.
Resuming don't change Under Tool > External Tools the baudrate.Keep it as is. This is just the baud at upload speed!
Yeah but why does it work after uploading it with the IDE but not if I'm using Atmel Studio?

Divinity82

#3
May 14, 2015, 07:29 pm Last Edit: May 14, 2015, 07:34 pm by Divinity82
Baudrate is not simply an upload speed, it is the rate of transmission specific to communication. The baudrate in the ide environment must exactly mach the baudrate of the controller. Think of it like walkie-talkies. If I am on channel 1 and you on channel 2, we can't communicate.
So when changing the baudrate in you code, make sure you also set it the same in the program also.

 I'm not too familiar with atmel Studio but doesn't it use virtual terminal or something? Whatever serial monitor they use, change the baudrate there to what you specified in your code.
Impossible is only a concept!

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy