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

Back to Subject List

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


 
Msg Score: +1
 +1 Good Answer/Helpful
#176610 - Like I said before....
Responding to: ???'s previous message
Like I alluded to before....stop trying to make this so complicated.

For each specific MCU family that you decide to support you should actually find that there should be a complete .H file with _all_ if the SFR definitions for that family. You could include each of those with your code set and then have a conditional include statement sequence that uses a reference to a #define'ed MCU type number that selects the correct .H file to load for that MCU family. Put the MCU selection #define into a "target.h" file that you include into each source file at the top before all other #include's.

You could decide to break the general rule of not having #include's inside of #include's. If so you could put the following style code into the target.h file:

/* select the type of MCU you intend to use */
/* uncomment only one of the following #define's */
/* Note: If your MCU type is not shown in this selection list */
/* then see the user documentation as to how to add your type */
/* to this project. */

// #define SILABS_C8051F02x
// #define ATMEL_AT82S5x
#define NXP_P89V51RD2
// #define DALLAS_DS80C40x

#ifdef  SILABS_C8051F02x
#include SILABS_C8051F02x.h
#endif

#ifdef ATMEL_AT82S5x 
#include ATMEL_AT82S5x.h 
#endif

#ifdef NXP_P89V51RD2 
#include NXP_P89V51RD2.h
#endif

#ifdef DALLAS_DS80C40x
#include DALLAS_DS80C40x.h
#endif

 


In your source code modules wherever there is derivative specific code that accesses SFRs you include a set of conditionals just like those shown above but with the #include's replaced with the derivative dependent code sequence.

Do _not_ fall into the trap that you need to keep as much code as common as possible. Instead you can include a whole separate initialization subroutine or SFR access subroutine within each derivative dependent section.

When you make this layout like this it should be very easy for a customer/client/user of yours to follow what is going on and ,make the proper selection in the target.h file. And if they need to add a new MCU type you can provide easy instructions to show "add a conditional here and here and add a subroutine there.

I can repeat that you can clearly delineate in your customer agreement documentation that the code comes pre-configured and tested for a particular range of MCUs and that instructions are provided for a DIY procedure to add additional MCUs. You can then offer to support adding additional types for those customers that are willing to pay a fee for you to provide that service.

Michael Karas



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