Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Changing baudrate.

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
svberg

Bascom Member



Joined: 07 Nov 2011
Posts: 48

blank.gif
PostPosted: Fri Dec 14, 2018 3:02 pm    Post subject: Changing baudrate. Reply with quote

Hi.
I have bascom 2.0.8.1. and working with Arduino Mega with ATMEGA2560

I need to change baudrate runtime.

I start with config of the Com2;
Config Com2 = 19200 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0
Open "com2:" For Binary As #2

Later in the program I need to change this to 38.400 baud.
Have tried;
Baud2=38400
Baud #2,38400
But none work.
Some help please?
regards svein


(BASCOM-AVR version : 2.0.8.1 )
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Fri Dec 14, 2018 7:14 pm    Post subject: Reply with quote

As Config ComX ... is referred to as re-usable in the help file, did you actually try that?
Back to top
View user's profile
svberg

Bascom Member



Joined: 07 Nov 2011
Posts: 48

blank.gif
PostPosted: Fri Dec 14, 2018 7:43 pm    Post subject: Reply with quote

Yep.
ried a new config with the new baudrate, but when compiling I get;
"Com port already open"

Then I tried a Close #2 before config, but same result.
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Fri Dec 14, 2018 10:10 pm    Post subject: Reply with quote

should be Baud1=38400 for the second uart. baud works on the first uart. I know,it is confusing.
Using # should work too.
you show just some fragments, you should show some more complete code that includes the $regfile

try with a terminal emulator if it work or not.

also a CONFIG can be used multiple times as MWS suggest but not the OPEN statement. OPEN and CLOSE multiple dynamic use is for file handling. So use the OPEN just once. But config COM can be used twice or more. If not show the code.

_________________
Mark
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum