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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/07/06 13:45
Read: times


 
#119814 - It's illogical, Captain...
Responding to: ???'s previous message
void externalinterrupt(void) interrupt 0    
{
   if( !flag )
   {
      // At this point, flag must be false
      TR0  = 1;    
      flag = !flag; // Toggle the flag;
                    // since it must originally have been false,
                    // it must now be true
   }

   // At this point, flag must be true:
   // either it was originally true, so the above code was skipped;
   // or it was originally false, and the above code set it true!

   // Therefore, this test next is pointless - flag is always true!
   if( flag )
   {
      TR0 = 0;   //disable timer0
      IEN0 = 0x00;    //disable all interrupts

      flag = !flag;   // Again, since flag must have been true
                      // might just as well set it to false directly here!

      timercounts = (TH0*256) + TL0;
      time = timercounts/921583;
      rpm = (unsigned int)(30/time);
   }
}



See: http://www.8052.com/forum/read.phtml?id=117098

List of 25 messages in thread
TopicAuthorDate
frequency of a digital pulse            01/01/70 00:00      
   Variable definitions ?            01/01/70 00:00      
      Please post formatted code            01/01/70 00:00      
   Some points:            01/01/70 00:00      
   misconceptions cleared            01/01/70 00:00      
      inappropiate response            01/01/70 00:00      
         the entire problem again            01/01/70 00:00      
            flag=!flag ?            01/01/70 00:00      
               The value of Flag is known!            01/01/70 00:00      
                  I see, but I don't C            01/01/70 00:00      
               It's illogical, Captain...            01/01/70 00:00      
                  It is worse than that            01/01/70 00:00      
            nope            01/01/70 00:00      
            Please post formatted code!!            01/01/70 00:00      
               he did follow the instructions            01/01/70 00:00      
                  Oh no he didn't!            01/01/70 00:00      
                     Argument            01/01/70 00:00      
                     well, I saw the indentions and - shame            01/01/70 00:00      
            formatted code.................            01/01/70 00:00      
               thus therefore undefined            01/01/70 00:00      
               Formatted, but not the same code!            01/01/70 00:00      
            2 problems off the top            01/01/70 00:00      
               a blatant understatement            01/01/70 00:00      
      Implicit casting mess.            01/01/70 00:00      
   commentless code is worthless            01/01/70 00:00      

Back to Subject List