PDA

View Full Version : Baud Rate declared as a Constant



mikendee
- 17th February 2010, 08:45
Hi,
I have just stumbled onto a problem. If I declare the baud mode on SEROUT2 as a constant it compiles Okay but doesn't work.
eg:
BAUD CON 84
SEROUT2 PORTB.2, BAUD,["TEST",13]

But this does work
BAUD var Byte
BAUD = 84
SEROUT2 PORTB.2, BAUD,["TEST",13]

I have tried it with both 16F88 and 18F4550 pics and I have seen this method used in other posts such as http://www.picbasic.co.uk/forum/showthread.php?t=3789.

Is this usual or is it just me or my programmer or something.
Thanks for any ideas. Mike

mackrackit
- 17th February 2010, 08:55
Try


BAUD VAR WORD

mikendee
- 17th February 2010, 18:17
Thanks for your reply Dave.

BAUD Var Word works as does Byte if its less than 255.

My question is why doesn't CON work when I can't find any reference to it in the Manual and espesially as Bruce had it in some code at http://www.picbasic.co.uk/forum/showthread.php?t=3789

Maybe it works in PM but not MPASM.

Mike

mackrackit
- 17th February 2010, 18:37
Sorry, I read it backwards.

BAUD CON 84
should work fine. And I never use PM...

So I do not know why it does not work for you.

mikendee
- 17th February 2010, 19:05
Okay, thanks Dave.
I'll just have to put it down to another one of those weird things that happens.
Cheers,
Mike