Just look at any ASCII chart to understand what's happening.
With PBP most people assume sending serial data goes something like this;
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.Code:X VAR BYTE X = 123 Main SEROUT2 0,16468,[DEC X] PAUSEUS 200 GOTO Main
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




Bookmarks