Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/31/06 21:29
Read: times


 
#123471 - ^= , Checksum, Problem
Having a problem computing an LRC checksum.
This compiles OK, but the Checksum I end up with is FF no matter what. Am I just using this "^=" operator wrong?

Checksum = 0xFF; //-Initialize checksum
while (!TI0);
TI0 = 0;
SBUF0 =0x01;//SOF
while (!TI0);
TI0 = 0;
SBUF0 = Len; // Length of frame incl. Len excl. Chcksm
Checksum ^= Len;
while (!TI0);
TI0 = 0;
SBUF0 = Type;
Checksum ^= Type;
while (!TI0);
TI0 = 0;
SBUF0 = Cmd;
Checksum ^= Cmd;
while (!TI0);
TI0 = 0;
SBUF0 = Node;
Checksum ^= Checksum;
while (!TI0);
TI0 = 0;
SBUF0 = CommLen; //data payload length (button,pressed state)
Checksum ^= CommLen;
while (!TI0);
TI0 = 0;
SBUF0 = CommClass; // COMMAND_CLASS_BASIC
Checksum ^= CommClass;
while (!TI0);
TI0 = 0;
SBUF0 = Comm;//Basic_Set
Checksum ^= Comm;
while (!TI0);
TI0 = 0;
SBUF0 = (LastKey);
Checksum ^= LastKey;
while (!TI0);
TI0 = 0;
SBUF0 = TXOpt; //tx option ACK needed
Checksum ^= TXOpt;
while (!TI0);
TI0 = 0;
SBUF0 = FuncID; //dummy funcID
Checksum ^= FuncID;
while (!TI0);
TI0 = 0;
SBUF0 = Checksum;

Using Keil Compiler, running on a Silabs C8051F330 if that matters.
Thanks

List of 24 messages in thread
TopicAuthorDate
^= , Checksum, Problem            01/01/70 00:00      
   Have you tried a simulator?            01/01/70 00:00      
      well,            01/01/70 00:00      
      OK            01/01/70 00:00      
   volatile?            01/01/70 00:00      
      volatile            01/01/70 00:00      
         using ICE ?            01/01/70 00:00      
            update code (working) and clarification            01/01/70 00:00      
               Style            01/01/70 00:00      
               Think about your variable types            01/01/70 00:00      
                  Thanks            01/01/70 00:00      
                     Magic numbers            01/01/70 00:00      
                        but don't be "oversmart"            01/01/70 00:00      
                           example?            01/01/70 00:00      
                           advantages            01/01/70 00:00      
                              the most often forgotten quality guarantee            01/01/70 00:00      
                     so, use structures!            01/01/70 00:00      
                        padding            01/01/70 00:00      
                   and             01/01/70 00:00      
                     Actual Output            01/01/70 00:00      
                     C99            01/01/70 00:00      
                        making up your own            01/01/70 00:00      
                           Names            01/01/70 00:00      
                     FYI - C99 Exact- & Minimum-width types            01/01/70 00:00      

Back to Subject List