Pages: [1]   Go Down
Author Topic: Serial baud rate adjustment without reset?  (Read 756 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 85
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

Is it possible to adjust the baudrate of the serial port without a reset?

Thanks,

-ren
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 228
Posts: 14053
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Yes, something like this
Code:
void setup()
{
  Serial.begin(9600);
  Serial.print("press A for high speed mode, any other key to keep 9600");

  while(Serial.available == 0);
  if (Serial.Read() == 'A') Serial.begin(115200);
}

void loop()
{
  Serial.println("Hello world");
  delay(1000);
}
 
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 41
Posts: 4435
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Yes, something like this...
How does this get around the auto reset feature?

Don
Logged

Offline Offline
Faraday Member
**
Karma: 66
Posts: 2588
Now, More Than Ever
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Everything passes through setup (), but you can place a call to Serial.begin() anywhere.  I think it's commonplace having Serial.begin( ); in the setup(), but it could be put in a baudrate function all its own. 
Logged

"Hello, I must be going..."
"You gotta fight -- for your right -- to party!"
Don't react - Read.
"Who is like unto the beast? who is able to make war with him?"

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 228
Posts: 14053
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


biggest problem is that you have to synchronize the sender / receiver when switching. But you can make a sort of "encrypted" communication by switching the baudrate per byte.

NOte that the hardware can do almost any baudrate where software serial has the standard values .

Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 85
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

robtillaart,

Thanks, I suspected that could call begin twice, but I wasn't sure...thanks for clearing it up.

-ren
Logged

Pages: [1]   Go Up
Jump to: