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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/08/10 15:30
Read: times


 
#176520 - Thanks...
Responding to: ???'s previous message
Thanks Andy & Michael. That all makes pretty good sense.

Yes, my concern in adding the CKCON definition to my module, centred about what happens when an end-user replaces the originally #included generic 80C31/ 80C51 register declaration header file. This file doesn't have the clock control register declaration, yet a more controller specific register declaration header file most likely will. The minute the register declaration header file is replaced, the compiler throws an unhappy CKCON register redefinition error.

There turns out to be an embarrassingly simple solution to my dilemma. I simply declare the CKCON register in my module, conditionally on the presence of the original generic 80C31/ 80C51 register declaration header file's header guard define REG51_H in my project. As soon as the REG51.h file is replaced with something like AT89C51AC3.h, then the header guard declaration REG51_H disappears, and so does my previously superfluous CKCON register declaration.

#ifdef REG51_H
/*
 * Declare CKCON clock control register only if this module still #includes
 * it's original generic 8051 register declaration header file REG51.h. 
 */
sfr CKCON = 0x8F;
#endif


Thanks for the valuable input, guy's. That's helped me to better understand the difference between pre-processor definitions and compiler declarations, as well as to make better use of header guard definitions. Cool!

Regards,
Murray R. Van Luyn.

List of 34 messages in thread
TopicAuthorDate
Conditional SFR Declaration?            01/01/70 00:00      
   ReDef            01/01/70 00:00      
   Preprocessor -vs- Compiler            01/01/70 00:00      
      Thanks...            01/01/70 00:00      
   A Loosely Related Query?            01/01/70 00:00      
      .h file            01/01/70 00:00      
         Yep, that works!            01/01/70 00:00      
            I would not            01/01/70 00:00      
               Good question...            01/01/70 00:00      
            A Rethink...            01/01/70 00:00      
               I don't know ... but            01/01/70 00:00      
                  Agree with Michael            01/01/70 00:00      
                  An overthink.            01/01/70 00:00      
               #including #includes            01/01/70 00:00      
                  totally?            01/01/70 00:00      
                     re: really?            01/01/70 00:00      
   Still no luck...            01/01/70 00:00      
      Like I said before....            01/01/70 00:00      
      HAL            01/01/70 00:00      
      just curious            01/01/70 00:00      
         Nicely workable solution found...            01/01/70 00:00      
            Post vandalised!            01/01/70 00:00      
               What do you mean ...            01/01/70 00:00      
                  I mean this...            01/01/70 00:00      
                     Vandalism Highly Doubted            01/01/70 00:00      
                        Thanks Michael.            01/01/70 00:00      
      Define a new sfr?            01/01/70 00:00      
         RE: This assumes that location 0x8E is always the register            01/01/70 00:00      
         Simplest Solution?            01/01/70 00:00      
            I think HAL is less risky?            01/01/70 00:00      
               HAL very interesting...            01/01/70 00:00      
                  RE: might not be so immediately well understood            01/01/70 00:00      
                     Ah, now I see...            01/01/70 00:00      
                        No, you don't need a HAL header file for each variant!            01/01/70 00:00      

Back to Subject List