HSERIN seems to fail and I can't see WHY


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2006
    Location
    China
    Posts
    266

    Default HSERIN seems to fail and I can't see WHY

    Hi,

    Baudrate 9600 just for safe.

    I have a need to read a String of 256 characters from a PC and I would like to use the HSERIN command. There is a lovely little modifier STR that would allow me to do this. To test this I turn on a LED when waiting for the String, and as soon as I pass this line in my code I turn the LED off.

    LED=1
    HSERIN [STR RxData\64]
    LED=0

    First I tried with a shorter string of 64 chars and it works nice BUT when I increase the number to RxData\256 the command behaves in the same way as if I would have set it to \0. The led flashes and that's it, even if I send nothing to the PIC. It just skips the command....

    I am using a 18F4620 and according to the "Manual" arrays used in 18-series can span Banks and are ONLY "limited in length by the amount of memory"


    Bug or feature or did I miss some important part in the Holy Book of Pics?

    /j

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Hi Jumper,

    After looking at the PBPPIC18.lib file, it appears that the STR modifier is limited to a single byte for the "digit count". So 255 will be the maximum.

    See if this helps...
    Code:
    HSERIN [STR RxData\255, RxData(255)]
    <br>
    DT

  3. #3
    Join Date
    Mar 2006
    Location
    China
    Posts
    266


    Did you find this post helpful? Yes | No

    Default Any different?

    Thanks for the answer and your idea works, it it any different if I use that way or:

    for n=o to 255
    HSERIN [RxData(n)]
    next n

    except it compiles in different size?

    by the way,

    I was trying to load a Byte from the RxData array into the lowbyte and high byte of a word array "C_Data(x)". What would be the best way of doing (since this is not allowed)?

    C_Data(x).Lowbyte=RxData(n)
    C_Data(x).HighByte=RxData(n+1)

    I solved this loading with using a Melanie suggested method "C_Data.lowbyte(i) =RxData(n)" but this requires that you adresses the C_Data.Lowbyte(i) not using the word count but the position of the byte in the word array so the Highbyte iadresses as C_data.Lowbyte(i+1).

    I couldn't even get a temporary word variable to work but that could have been because of the time of the day.

    This should work right??

    Temp.Lowbyte=RxData(n)
    Temp.HighByte=RxData(n+1)
    C_Data(i)=Temp




    Not that user friendly ;-) (at least not 3 am)

    /j

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Jumper
    Thanks for the answer and your idea works, it it any different if I use that way or:

    for n=o to 255
    HSERIN [RxData(n)]
    next n
    That'll work just as well. Wouldn't be the case with SERIN2, but with HSERIN it's fine.

    I was trying to load a Byte from the RxData array into the lowbyte and high byte of a word array "C_Data(x)". What would be the best way of doing (since this is not allowed)?
    Here's another possibility...
    Code:
    C_Data(i)=RxData(n) << 8 + RxData(n+1)
    or...
    Code:
    RxData   VAR BYTE[256]
    RxDataW  VAR WORD EXT
    @RxDataW = RxData
    
    ; -- then later on ---
    
    C_Data(i) = RxDataW(n/2)
    But the second one assumes the data in the byte array is aligned to word boundaries, which may not be the case.
    <br>
    DT

Members who have read this thread : 0

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