Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Disabling HW-UART with not using $baud (solved)

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
laborratte

Bascom Expert



Joined: 27 Jul 2005
Posts: 262
Location: Berlin

germany.gif
PostPosted: Mon May 30, 2011 6:18 pm    Post subject: Disabling HW-UART with not using $baud (solved) Reply with quote

Hi,
I recently disabled the HW-UART (when pins needed for other stuff) just by not using the statement
Code:
$baud=9600 'or whatever for baudrate needed

Now with version 2.0.5.0 I got the error message
Code:
Error : 70    Line :   996   BAUD rate not possible [-32768]  , in File ...

until I write the $baud statement in my code - which introduced the not wanted UART-setup.

Is this an new feature or a bug?

P.S.
I know how to disable the UART by hand with
Code:
UCSR0B.RXEN = 0
UCSR0B.TXEN = 0

I just want to know if I have to change that on my existing programs....


Last edited by laborratte on Tue May 31, 2011 4:35 pm; edited 1 time in total
Back to top
View user's profile
ajvuik

Bascom Member



Joined: 28 Apr 2011
Posts: 46
Location: Netherlands

netherlands.gif
PostPosted: Mon May 30, 2011 6:48 pm    Post subject: Reply with quote

I recently played around with UART in a Mega8. Are you trying to do something with the soft UART? I don't know for sure of-course, because I don't know the rest of your code, but you could try:

Code:

baud = 9600
 


instead of:

Code:

$baud = 9600
 


the second code will invoke the hardware UART if your chip has one, the first is just a statement indicating how fast you want a serial communication to work.

Atleast, that's how I understand it from the help files.

some one with more knowledge will correct me if I'm wrong.

regards
Back to top
View user's profile
laborratte

Bascom Expert



Joined: 27 Jul 2005
Posts: 262
Location: Berlin

germany.gif
PostPosted: Mon May 30, 2011 7:10 pm    Post subject: Reply with quote

I don't want to use UART at all. I need the pins for other stuff.

I think most people want to use the UART so Bascom's normal behavior is to prepare the UART and using the value given in $baud fot baudrate. Till now I could disable the UART just by commenting $baud out. Then the compiler didn't include the UART setup. This seems to be changed now.
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5071
Location: Holland

blank.gif
PostPosted: Mon May 30, 2011 7:59 pm    Post subject: Reply with quote

it was not changed. I can not reproduce it either.
best to send a zipped sample to support.

_________________
Mark
Back to top
View user's profile Visit poster's website
mattcro

Bascom Member



Joined: 03 Oct 2007
Posts: 324
Location: Scotland

uk.gif
PostPosted: Mon May 30, 2011 8:10 pm    Post subject: Reply with quote

If you don't specify $baud in your code, the compiler uses whatever is set in the compiler options (Options>Compiler>Communication). If you have a silly value set here (like "1") then the compiler can't calculate the required baud divisor value and fails with that error.

Note that the compiler doesn't actually generate any UART code unless you put $BAUD in your code or use PRINT, INPUT, etc.

_________________
If all else fails, read the manual. Even better: read the manual before something fails. If you can't find it in the manual, search the forum.
BascomAVR 2.0.8.2
Back to top
View user's profile
Visovian

Bascom Member



Joined: 31 Oct 2007
Posts: 584
Location: Czech

czechrepublic.gif
PostPosted: Tue May 31, 2011 5:07 am    Post subject: Reply with quote

Quote:
Note that the compiler doesn't actually generate any UART code unless you put $BAUD in your code or use PRINT, INPUT, etc.
But it still occupies tx and rx pins. To release them use
Code:
UCSRB = 0
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 1827

blank.gif
PostPosted: Tue May 31, 2011 9:31 am    Post subject: Reply with quote

Visovian wrote:
But it still occupies tx and rx pins.

This statement is wrong. If the code doesn't contain anything serial-related, the UART isn't connected to the pins and they have their normal function.
Back to top
View user's profile
laborratte

Bascom Expert



Joined: 27 Jul 2005
Posts: 262
Location: Berlin

germany.gif
PostPosted: Tue May 31, 2011 1:03 pm    Post subject: Reply with quote

Sorry, I forgot to say that I'm not using the IDE. The following code is working under 1.11.9.5:

Code:
'Program "baudtest.bas"
$REGFILE    = "m128def.dat"
$CRYSTAL    = 8000000
$FRAMESIZE  = 32
$HWSTACK    = 10
$SWSTACK    = 40

'$BAUD       =  9600  (commented out)

do
loop


Compiling with command
Code:
bascomp.exe baudtest.bas SS=40 FR=32 HW=10 CHIP=20
 


Under Version 2.0.5.0 and (just tested) 2.0.6.0 the error message
Code:
Error : 70    Line :   16    BAUD rate not possible [-32768]  , in File : ...Baudtest.bas

is generated.
OS is Win7 x64.
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5071
Location: Holland

blank.gif
PostPosted: Tue May 31, 2011 2:56 pm    Post subject: Reply with quote

It was caused by a change in the report module. I changed it.
_________________
Mark
Back to top
View user's profile Visit poster's website
laborratte

Bascom Expert



Joined: 27 Jul 2005
Posts: 262
Location: Berlin

germany.gif
PostPosted: Tue May 31, 2011 4:09 pm    Post subject: Reply with quote

Mark,
thank you. As always in the last 10 years: perfect support!
Very Happy
Back to top
View user's profile
athomeelectronics

Bascom Member



Joined: 13 Jun 2007
Posts: 60

finland.gif
PostPosted: Tue May 31, 2011 7:38 pm    Post subject: Reply with quote

albertsm wrote:
It was caused by a change in the report module. I changed it.


Albert,

recently, there was also something wrong with baud rate error calculation on Xmega chips (report said 100% error or something). That was corrected, thanks for that.

But, there's still always error "High Baud rate error in line 0".

You can test this with code:

Code:
$regfile = "xm128a1def.dat"
$crystal = 32000000
$lib "xmega.lib"

Config Osc = Enabled , 32mhzosc = Enabled , 32khzosc = Enabled
Config Sysclock = 32mhz , Prescalea = 1 , Prescalebc = 1_1
Config Priority = Static , Vector = Application , Lo = Enabled
Config Com4 = 38400 , Mode = 0 , Parity = None , Stopbits = 1 , Databits = 8
Open "COM4:" For Binary As #4
Enable Interrupts

Do
NOP
Print #4 , "abc"
Loop
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5071
Location: Holland

blank.gif
PostPosted: Tue May 31, 2011 8:31 pm    Post subject: Reply with quote

The name is Mark, not Albert (Alberts is my sure name) Smile
This was a warning, I changed it.

_________________
Mark
Back to top
View user's profile Visit poster's website
Visovian

Bascom Member



Joined: 31 Oct 2007
Posts: 584
Location: Czech

czechrepublic.gif
PostPosted: Wed Jun 01, 2011 6:38 am    Post subject: Reply with quote

MWS:
You are right.
I had tested it in some wrong way.
Back to top
View user's profile
athomeelectronics

Bascom Member



Joined: 13 Jun 2007
Posts: 60

finland.gif
PostPosted: Wed Jun 01, 2011 6:56 am    Post subject: Reply with quote

albertsm wrote:
The name is Mark, not Albert (Alberts is my sure name) Smile
This was a warning, I changed it.


Thanks for changing that, Mark Smile
Back to top
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive 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