Creating Checksum in PBP


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Just look at any ASCII chart to understand what's happening.

    With PBP most people assume sending serial data goes something like this;
    Code:
    X VAR BYTE
    X = 123
    
    Main
        SEROUT2 0,16468,[DEC X]
        PAUSEUS 200
        GOTO Main
    You would assume you're sending a single byte, but PBP is first converting your three decimal digits in X into three separate ASCII characters, and sending a total of three bytes. "1" then "2" then "3". That's what the DEC modifier does.

    So your PC isn't receiving a single byte value of 123. It's receiving three separate bytes. ASCII characters 1 then 2 then 3. This is what it's using to calculate the checksum.

    Since your PC checksum program runs a cumulative checksum calculated from each separate ASCII digit, you just need to do the same with your PIC-based cheksum program before sending the final checksum result to the PC.

    Try running this with a PIC connected to your PC serial port, and see what displays in a terminal window.
    Code:
    X = 123
    
    Main
        HSEROUT [DEC X,13,10]
        HSEROUT [X,13,10]    
        PAUSEUS 2000
        GOTO Main
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  2. #2


    Did you find this post helpful? Yes | No

    Post

    Hi,

    The attached file may be of some help.

    Cheers.
    Attached Images Attached Images
    ---> picnaut

Similar Threads

  1. PBP Book
    By Bruce in forum Off Topic
    Replies: 83
    Last Post: - 4th October 2021, 12:55
  2. Checksum
    By retepsnikrep in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 24th October 2009, 04:09
  3. Calculate Byte Value Checksum in PBP Pro
    By Pedro Pinto in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 8th July 2009, 22:50
  4. Replies: 1
    Last Post: - 10th May 2006, 15:17
  5. Checksum problem!
    By atomski in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 3rd November 2004, 07:21

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