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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
04/17/08 12:55
Read: times


 
#153607 - the old nugget
Responding to: ???'s previous message
(OK, if you want something more sophisticated, it can be hidden behind some obscure manipulation with the whole SFR byte).
I have, in old code, way too often found that some (re)setting of a bit was hidden in a mov sfr,#xxh.

For that reason I started some years ogo to use 'definition tables' where EACH and EVERY occurance of a bit or a SFR could be found by a global search.

example:
sfr     SF_TCON         = 0x88;
  sbit    SB_TCON_IT0     = 0x88;
  #define SM_TCON_IT0       0x01
  sbit    SB_TCON_IE0     = 0x89;
  #define SM_TCON_IE0       0x02
  sbit    SB_TCON_IT1     = 0x8A;
  #define SM_TCON_IT1       0x04
  sbit    SB_TCON_IE1     = 0x8B;
  #define SM_TCON_IE1       0x08
  sbit    SB_TCON_TR0     = 0x8C;
  #define SM_TCON_TR0       0x10
  sbit    SB_TCON_TF0     = 0x8D;
  #define SM_TCON_TF0       0x20
  sbit    SB_TCON_TR1     = 0x8E;
  #define SM_TCON_TR1       0x40
  sbit    SB_TCON_TF1     = 0x8F;
  #define SM_TCON_TF1       0x80
thus e.g. TR0 can be found in both
orl SF_TCON,#SM_TCON_TR0
and
sbit SB_TCON_TR0
likewise any access to TCON can be found
also, since the SFR name is in all definitions (theoritically it is not needed for the SM_.. as TCON would be in that line) the chance of using a bit name not associated with that correct SFR (YES, I have fond such bugs in somebodys code) is minimized.

Erik



List of 14 messages in thread
TopicAuthorDate
Interrupt-driven Rx, polled Tx            01/01/70 00:00      
   this is why we have the FAQs...            01/01/70 00:00      
      Maybe I'm crazy            01/01/70 00:00      
         if you do that            01/01/70 00:00      
         Polled transmission            01/01/70 00:00      
            Mixing modes on UART            01/01/70 00:00      
   Here's why I asked            01/01/70 00:00      
      the risks of doing things the "wrong way"            01/01/70 00:00      
         the old nugget            01/01/70 00:00      
            Cool idea            01/01/70 00:00      
               size            01/01/70 00:00      
         Is the \"wrong way\" risky, or just stupid?            01/01/70 00:00      
            explanation            01/01/70 00:00      
               Thanks. I understand now what you are saying            01/01/70 00:00      

Back to Subject List