Go Down

### Topic: 300 Baud for Mega 2560 (Read 1 time)previous topic - next topic

#### inspectorCleve

##### Jun 20, 2012, 09:53 pm
Hello,
when looping back my via

if (Serial.available())
{
Serial.write(inByte);
}

It only returns rubbish - when using 300 Baud
With every other Baud rate it works.

Do I get that right, that the Ports 1 and 2 will work with 300 baud?

How can I get my USB run with 300 Baud?

Thanks & regards
Nils

#### xolroc

#1
##### Jun 20, 2012, 11:44 pm
The real question here is "Why do you want to use 300 baud"?  For serial communication, that's ridiculously slow!

#### inspectorCleve

#2
##### Jun 27, 2012, 09:37 am
Indeed this is very slow - I would appreciate if my power meters I would like to communicate with would be faster. But there is no chance to speed those devices up  =(

#### Tom Carpenter

#3
##### Jun 27, 2012, 02:05 pm
In arduino, set it to 600BAUD, then turn of double speed. (the baud rate will then half)

Code: [Select]
`Serial1.begin(600);UCSR1A &= ~(1<<U2X1);`

Basically, the BAUD rate generator can only store 12bit values. By default Arduino turns on double speed, which means that the generator value is:

UBRRn = fcpu/(8*BAUD) -1
For 300baud, this is
UBRRn = 16000000/(8*300) -1 = 6665.
This is a 13bit number, so cannot be stored. (If you try and save it, it will be truncated to 2569 = 6250BAUD, hence you have a problem)

By disabling the double speed bit, the calculation becomes:
UBRRn = fcpu/(16*BAUD) -1
For 300baud, this is
UBRRn = 16000000/(16*300) -1 = 3332.
This nicely fits into 12 bits, so you will be able to easily generate 300 BAUD.
~Tom~

#### inspectorCleve

#4
##### Jun 28, 2012, 10:06 pm
This sounds great!!!
I will try this and give my feedback asap
Thanks
Cheers Nils

#### inspectorCleve

#5
##### Jul 12, 2012, 03:45 pm
No - this Does not work
But I will follow up on this later - perhaps I have to equip with another Peace of hardware which is faster  :~
If not I will follow up

Thanks

#### Tom Carpenter

#6
##### Jul 13, 2012, 07:26 pm
This works for me:
Code: [Select]
`void setup() {  // put your setup code here, to run once:  Serial.begin(600);  UCSR0A &= ~(1<<U2X0);}void loop() {  // put your main code here, to run repeatedly:  Serial.println("HI, I'm 300BAUD");  delay(1000); }`

I see now that you wanted to send it through the USB not throught UART1. The code above communicates fine with the computer (through UART0 and hence the USB port) with x-ctu (terminal) set at 300 baud.
~Tom~

Go Up

Please enter a valid email to subscribe