PDA

View Full Version : HSERIN vs Serin2



Rob
- 12th February 2008, 15:35
Hi,

I can get my PIC18F4550 to receive some data correctly by using:



serin2 PORTC.7,84,[wait ($FD), dec databyte[0],dec databyte[1],dec databyte[2],_
dec databyte[3],dec databyte[4],dec databyte[5]]


but not this:



hserin [wait ($FD), dec databyte(0),dec databyte(1),dec databyte(2),_
dec databyte(3),dec databyte(4),dec databyte(5)]


my defines for the Hardware Serial in are:



define HSER_RCSTA 90h ' Set receive register to receiver enabled
define HSER_TXSTA 24h ' Set transmit register to transmitter enabled
define HSER_BAUD 9600 ' Set baud rate to 9600
define HSER_CLROERR 1 ' Set to automatically clear overrun errors


As far as I can see, everything is the same. It's even the same PIC pin!

Any help would be much appreciated!

Cheers

Rob

rwskinner
- 12th February 2008, 17:32
Not sure if this has anything at all to do with it but you are using square brackets around your array elements in one then parens in the other.

skimask
- 12th February 2008, 17:53
Not sure if this has anything at all to do with it but you are using square brackets around your array elements in one then parens in the other.

That'll do it alright...

Rob
- 13th February 2008, 09:26
Thanks for the replies.

I have tried the HSERIN with both square brackets and parentheses but neither way works unfortunately. It seems very strange to me that the HSERIN will not work with the data I am trying to receive (I have used it a fair few times in the past with no problems). It seems to be set up the same way as the SERIN2 i.e. 9600 baud, no parity bit, 8 data bits, 1 stop bit and the SERIN2 is receiving in True form.

Any other pointers please?

Cheers

Rob

P.S. I am using the round brackets because of post #2 here by Darrel:
Post #2

Rob
- 13th February 2008, 10:46
Hmmmm,

some more testing shows that:



hserin [wait ($FD)]


allows the program to continue whereas



hserin [wait ($FD), dec databyte(0)]


does not.

However, if I put my original string in but with the DEC modifier removed, the code works fine:



hserin [wait ($FD), databyte(0), databyte(1), databyte(2), databyte(3), databyte(4), databyte(5)]


I have also tried the HEX modifier but again this prevents the code from progressing. Very strange

Angus Anderson
- 13th February 2008, 12:52
Rob-

I think that you have to specify the no of decimal digits to be output ie

DEC 3 Databyte(0) will print databyte(0) with 3 decimal digits and leading zeroes

regards

Angus Anderson

skimask
- 13th February 2008, 16:50
Rob-
I think that you have to specify the no of decimal digits to be output ie
DEC 3 Databyte(0) will print databyte(0) with 3 decimal digits and leading zeroes
regards
Angus Anderson

Not only that, but I think the DEC modifier kicks out the value (i.e. dies a horrible death :) ) if a non DEC capable value tries to get passed to the variable.