Searching \ for '[PIC]: problem understanding code in AN724' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/microchip/devices.htm?key=pic
Search entire site for: 'problem understanding code in AN724'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: problem understanding code in AN724'
2001\01\08@101431 by Oluseyi Odeinde

flavicon
picon face
hello everyone,

I am currently reading through the microchip application note AN724
which invloves implementing PPP on the microchip. I have read through
the documentatoin with little difficulty until now.  I am now having
problems undestanding some aspects of the code in appendix A of this
same application note.

In the main loop, after the login script, the code goes into a loop
where it tries to ping:

 // State machine loop until successful ping or PPP negotiation timeout

  for (TIME_SET(0);;) {
     if (TIME>7000 || number>20) PORTB&=0xF7;
     if (serial_rx_ready()) {               // Incoming character?
        PORTB ^=1;                          // Turn on Rx LED
        c = serial_get();                   // get the character
        if (serial_error()) serial_fix();   // clear Rx errors
        if (c == 0x7E) {                    // start or end of a packet

           if (rx_ptr && (checksum1==0xF0B8))

my problem is in understanding the last line in the code above. as i
understand it, we test to see if the character 'c' received signifies
the start or end of a packet therefore based on this how can we know
what value of checksum to check for (hope that makes sense). my other
question is that what is the significance of the value 0xF0B8 which is
used above? why should checksum1 be compared to this value?

Any help what so ever will extremely appreciated.

Seyi
P.S. the source code can be dowloaded at this link:

http://www.microchip.com/10/appnote/category/internet/00724/indexZIP0.htm

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2001\01\08@121520 by Bill Westfield

face picon face
            if (c == 0x7E) {                    // start or end of a packet
               if (rx_ptr && (checksum1==0xF0B8))

   my problem is in understanding the last line in the code above. as i
   understand it, we test to see if the character 'c' received signifies
   the start or end of a packet therefore based on this how can we know
   what value of checksum to check for (hope that makes sense). my other
   question is that what is the significance of the value 0xF0B8 which is
   used above? why should checksum1 be compared to this value?

When you generate the CRC for a packet, the field where the CRC itself will
be placed is set to zero, and you get a "real" CRC.  Rather than repeat this
process on reception, you perform the CRC caclulation on all the data
INCLUDING the received CRC field.  Because of the nature of the CRC
algorithm, this will yield a contant value (related to the polynomial and
perhaps the position of the CRC field in the packet, I would think) if the
CRC in the packet is correct.  If the CRC is incorrect (the packet is
damaged), you get some other value.  0xF0B8 happens to be the constant for
PPP and its CRC.

It's easier to see how this works with something simpler like the IP
checksum.  Since that's defined as the one's complement of the one's
complement checksum of the data, it's pretty obvious that the checksum of a
packet including a correct checksum will always be zero...

BillW

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...