HSERIN vs Serin2


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2005
    Location
    Essex, UK
    Posts
    94

    Default HSERIN vs Serin2

    Hi,

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

    Code:
    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:

    Code:
    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:

    Code:
        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

  2. #2
    Join Date
    Oct 2005
    Posts
    74


    Did you find this post helpful? Yes | No

    Default

    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.

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by rwskinner View Post
    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...

  4. #4
    Join Date
    Feb 2005
    Location
    Essex, UK
    Posts
    94


    Did you find this post helpful? Yes | No

    Default

    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

  5. #5
    Join Date
    Feb 2005
    Location
    Essex, UK
    Posts
    94


    Did you find this post helpful? Yes | No

    Default

    Hmmmm,

    some more testing shows that:

    Code:
    hserin [wait ($FD)]
    allows the program to continue whereas

    Code:
    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:

    Code:
    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
    Last edited by Rob; - 13th February 2008 at 10:47. Reason: Gramatical error

  6. #6


    Did you find this post helpful? Yes | No

    Default

    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

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Angus Anderson View Post
    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.

Similar Threads

  1. GPS $GPRMC to PIC16F684. Need help with SERIN2
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 27th November 2009, 09:47
  2. Getting SERIN2 to work?
    By BobPigford in forum mel PIC BASIC Pro
    Replies: 11
    Last Post: - 22nd July 2009, 20:10
  3. Should I use serin2 or HSERIN?
    By TonyA in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 20th April 2007, 16:05
  4. SERIN2 digit parsing
    By skimask in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 7th January 2007, 23:15
  5. Hserin not working...
    By robert0 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 22nd August 2005, 12:25

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts