This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Which header file to use with Silabs EFM8LB12F64

Dear all,

Would you help me to identify which header file to use with Silabs EFM8LB12F64E?

I already tried to compile a very simple program , but, failed.

 #include <SI_EFM8LB1_Register_Enums.h>
 sbit LED_Green = P1^4;

 sbit LED_Blue = P1^5;

 sbit LED_Red = P1^6;

 sbit PB0 = P0^2; //Push Button 0

 sbit PB1 = P0^3; //Push Button 1
  MCU_init(){

 // TO disable watchdog timer      do following

   WDTCN = 0xDE;

   WDTCN = 0xAD;

 //now, watchdog disabled
    CLKSEL = 0x88;     // Set system clock to 24.5 MHz
 //assign inputs

    P0MDIN=P0MDIN | 0x0C; //set bit 2 and 3 of P0 for DI

    P0MDOUT=P0MDOUT & 0xF3; // clear bit 2 and 3  of P0 for Open Drain

    P0^2 = 1;

    P0^3 = 1;
 //assign outputs

    P1MDIN=P1MDIN | 0x70; //set bit 4, 5 and 6 of P1 for DO

    P1MDOUT=P1MDOUT | 0x70; // set bit 4, 5 and 6 of P1 for Push-Pull

 }
 main()

 {

   MCU_init();
   while(1){
     if ( PB0 ^ PB1 )

      {

         LED_Green=1 ;

      }

           else

           {

           LED_Blue = PB0 ;

           LED_Red = PB1;

           }
           }

   }

Build operation resulted in following errors :

Build target 'Target 1'
compiling main.c...
..\main.c(1): warning C318: can't open file 'compiler_defs.h'
..\SI_EFM8LB1_Defs.h(34): warning C318: can't open file 'si_toolchain.h'
..\SI_EFM8LB1_Defs.h(39): error C141: syntax error near '0xE0'
..\SI_EFM8LB1_Defs.h(40): error C141: syntax error near '0xB6'
. .
. ..\SI_EFM8LB1_Defs.h(543): error C141: syntax error near '0xD8'
..\SI_EFM8LB1_Defs.h(544): error C141: syntax error near '0xD8'
..\main.c(5): error C202: 'P1': undefined identifier
..\main.c(6): error C202: 'P1': undefined identifier
..\main.c(7): error C202: 'P1': undefined identifier
..\main.c(8): error C202: 'P0': undefined identifier
..\main.c(9): error C202: 'P0': undefined identifier
..\main.c(13): error C202: 'WDTCN': undefined identifier
..\main.c(14): error C202: 'WDTCN': undefined identifier
..\main.c(18): error C202: 'CLKSEL': undefined identifier
..\main.c(21): error C202: 'P0MDIN': undefined identifier
..\main.c(22): error C202: 'P0MDOUT': undefined identifier
..\main.c(23): error C202: 'P0': undefined identifier
..\main.c(23): error C141: syntax error near '='
..\main.c(24): error C202: 'P0': undefined identifier
..\main.c(24): error C141: syntax error near '='
..\main.c(27): error C202: 'P1MDIN': undefined identifier
..\main.c(28): error C202: 'P1MDOUT': undefined identifier
..\main.c(37): error C202: 'PB0': undefined identifier
..\main.c(39): error C202: 'LED_Green': undefined identifier
..\main.c(43): error C202: 'LED_Blue': undefined identifier
..\main.c(44): error C202: 'LED_Red': undefined identifier
Target not created.
Build Time Elapsed: 00:00:01

It is obvious that the compiler cannot understand register names.

Please, help me to identify.

Best regards!

Parents
No data
Reply Children
  • http://www.keil.com/dd/chips/siliconlabs/8051.htm

    http://www.keil.com/dd/chip/8030.htm - indeed; no header listed.

    Again, I'd guess that SiLabs are just putting it all into their own tool.

    "Keil is ... common platform"

    Actually, Simplicity Studio is Eclipse - which is a far more common platform!

  • Doesn't Simplicity use the Keil compiler anyhow?

    it does, even a free full version

  • Silabs make header files for simplicity studio which looks to be based on eclipse IDE. I checked both Silabs and Keil's header files. Interestingly, Keil uses exactly same header files as Simplicity Studio which are located under /silabs/EFM8LB1 folder (3 files).

    I opened those and found that they are not using syntax of Keil header files. I modified the one that includes register definition and addresses myself.

    It works now.

    I really surprised !?

    Do I have to modify Keil's header files each time I use a different MCU? It looks weird. really!

  • I guess that SiLabs are focused on providing headers for their own tool?

    they do with some involved macros to make them Keil and SDCC compatible. Thus, just including the header w/o the associated macro(s) will not work

  • I removed everything, but register definitions and addresses.

    It works smoothly. No problem at all.

  • Do I have to modify Keil's header files each time I use a different MCU? It looks weird. really!

    not necessarily, only for those tat are 'universal'

  • Didn't Erik just say that you can use the SiLans headers:

    "they do with some involved macros to make them Keil and SDCC compatible. Thus, just including the header w/o the associated macro(s) will not work"

  • Didn't Erik just say that you can use the SiLans headers:

    "they do with some involved macros to make them Keil and SDCC compatible. Thus, just including the header w/o the associated macro(s) will not work"

    he did, maybe answering related to the posted problem made it unclear

    rephrasing my post

    "they do with some involved macros to make them Keil and SDCC compatible. Thus ...including the header with the associated macro(s) will work"

  • I made a hard modification to the header file. I don't believe it is intended to be so.It is unusual to make such a hard modification. KEIL has to provide a matching header.

  • Again - says who?

    See above - these headers are provided by the chip manufacturer.

    As Erik says, it should be "universal" - so it should work. You just have to supply the necessary definitions so that it knows it's in "Keil Mode".

    This is not uncommon.

  • The headers that are provided by Silabs are not functional with uV5.

    IMO, the "universal" header approximation is not reasonable since Keil is the seller of uV5. They have to provide a functional header if they say that it was supported by C51. On the other hand, why did they created headers for almost all other chips from Silabs and not for this one?

    Anyway, I created this topic to learn whether there is a header file. Now, I have learned there isn't.

    I created a custom made header and solved the problem.

    Thanks for all who responded!

    Best regards!

  • They have to provide a functional header if they say that it was supported by C51.

    Sorry, but that is total rubbish.

    Any decent seasoned programmer (such as, for example, Erik or Per) would know this and would not be in the least bit surprised if a precise header file for their chip was not available.

    Besides which, IMHO having to check over a header file and compare it against device documentation is a very good way to ensure you are gaining familiarity with the part.

  • "why did they created headers for almost all other chips from Silabs and not for this one?"

    Again, "they" is the chip manufacturer. When you say, "all other chips from Silabs", are you referring to the C8051 parts? Note that these were not originally from SiLabs, and pre-date the Simplicity Studio.

    So, as I said before, it's probably that SiLabs are now concentrating their efforts for new chips - such as the EFM8s - on their Studio.

    Anyhow, I just created a Blinky example in Simplicity Studio.

    The main 'C' file #includes SI_EFM8LB1_Register_Enums.h
    that header #includes SI_EFM8LB1_Defs.h
    which #includes si_toolchain.h

    It is si_toolchain.h which makes it all "universal":

    // -------------------------------
    // Keil/ARM C51
    //
    #if defined(__C51__)
    
    /// Used with pointers, declares a generic pointer.  Generic pointers
    /// work with any memory space but are inefficient.
    #define SI_SEG_GENERIC
    
    /// Declares a variable to be located in 8051 DATA space.
    #define SI_SEG_DATA data
    
    /// Declares a variable to be located in 8051 IDATA space.
    #define SI_SEG_IDATA idata
    
    /// Declares a variable to be located in 8051 XDATA space.
    #define SI_SEG_XDATA xdata
    :
    :
    

    The __C51__ symbol is automatically defined by the Keil compiler - so there's nothing you need to do.

    All of this is perfectly normal & standard for coping with multiple complilers.

    Just #includeing SI_EFM8LB1_Register_Enums.h - exactly as Simplicity Studio does - should work perfectly well in uVision.

    You will, of course, have to configure the uVision Include Paths correctly in the Project settings ...

  • KEIL has to provide a matching header.

    Keil does not have to do any such, here are 1000s of '51 derivatives. Also, the LB is quite new that if they were to do so, there has hardly been time.

    Keil could, of course, reassign their people to stop making compilers and make header files instead. What would you rather make yourself, a header file or a compiler?

    If you (sorry) think, you would realize that a C compiler does not 'know' anything about I/O, thus a perfect and to the spec C compiler does not include any header files

  • I'm with ibrahim hartavioglu on this one. Keil have a long history of providing single C51 part/family headers, not sure why they wouldn't at least offer the same for the EFM8, regardless of what SILabs do with other tools. Here's what I use for a current F340/F380 project:

    #include <c8051f340.h> // SFR declarations

    Done. All of those enum headers must have been some work. Can one be combined with a more generic header or do we still need a collection of headers to get one specific part functionality?

    I have a paid Keil installation, as of C8051F38x anyway, and was hoping to gather the correct header for an EFM8 device I'm considering. I'm not an Eclipse fan, but it's been a couple of years since I tried it. I guess one has to make their own like someone has done above. Maybe we can create a repository someplace for these. I will look at the more convoluted method SILabs now uses also. Was thinking that since my EFM8 part is just another variant (deviant? Hi Erik), that a single header would get me off to the evaluation races..