Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

CC1110 : SDCC generated .HEX file problem

Help
LostKeys
2010-05-10
2013-03-12
  • LostKeys
    LostKeys
    2010-05-10

    Hi,

    I try to program the CC1110 Texas Instrument chip using SDCC (V2.9.0) compiler with CodeBlocks as IDE but I get several troubles on the way I proceed to get an operative .HEX file!

    First of all, I compare the .HEX files produced between IAR and SDCC compilers for an empty main function : reading the .HEX files, I am very amazed that these files aren’t quit the same ! So, I just want to know if someone has already noticed this ? And if not, is there any additional option to set on compiler to resolve this problem ?

    Therefore, I still try to write a simple code which sets a CC1110 output to ‘0’ (this output drives a transistor which switches on a LED).

    #include  "Standard_Definition.h"
    #include  "CC1110.h"
    void  InitializeLEDs(BYTE LED);
    void  EnableLEDs(BYTE LED,BOOL On);
    void main()
    {
        InitializeLEDs(1);
        EnableLEDs(1,TRUE);
    }
    void  InitializeLEDs(BYTE LED)
    {
      switch(LED)
      {
        case 1:
          P1SEL&=~0x01;
          P1DIR|=0x01;
          break;
        case 3:
          P1SEL&=~0x08;
          P1DIR|=0x08;
          break;
      }
    }
    void  EnableLEDs(BYTE LED,BOOL On)
    {
      switch(LED)
      {
        case 1:
          P1_0=!On;
          break;
        case 3:
          P1_3=!On;
          break;
      }
    }
    

    So, I have checked that this program worked compiling it with IAR and sending it on the CC1110 chip to prove physically that the LEDs switched on. Then, I have used SDCC to compile the same program :
    • The .HEX file generated by SDCC is still different from the IAR generated file !
    • When I program the CC1110 with the SDCC generated .HEX file, the program didn’t work because the LED didn’t switched on !

    Consequently, I have changed the way I coded my program : instead of using user defined functions in the main function, I wrote the whole code in the main function !

    #include  "Standard_Definition.h"
    #include  "CC1110.h"
    void main()
    {
        P1SEL&=~0x01;
        P1DIR|=0x01;
        P1_0=0;
    }
    

    Compiling and programming the CC1110 with this program, I was surprised to see it working (the LED switched on !!!).

    So, I am wondering if I didn’t miss any settings to set up for the SDCC compiler. Moreover, if someone has any website addresses or documents which explain how I should proceed to use SDCC with CodeBlocks to program CC1110 chip, I would be thankful.

    Thanks

     
  • Maarten Brock
    Maarten Brock
    2010-05-11

    The first thing I would check is if this mcu has an enabled watchdog at startup. If so disable it in _sdcc_external_startup().

    And of course the hex file from IAR is totally different from the SDCC one. Even the hex file from SDCC 2.8.0 will probably differ from the one generated by SDCC 2.9.0.

     
  • LostKeys
    LostKeys
    2010-05-11

    Maarten, thanks for your quick response.

    I have checked the watchdog timer features for CC1110 MCU : it is not enabled at startup.

    So, I still have disabled it (if it could be necessary) by clearing the WDCTL register Enable bit in _sdcc_external_startup(). I have compiled and send this revised program on the MCU and it has no effect on his behaviour (LED never switched on with program calling EnableLEDs function)

     
  • Maarten Brock
    Maarten Brock
    2010-05-11

    What if you enable and switch on LED1 in main and LED3 through functions?

     
  • LostKeys
    LostKeys
    2010-05-11

    If I code the program like this :

    void  InitializeLEDs(BYTE LED);
    void  EnableLEDs(BYTE LED,BOOL On);
    void main()
    {
        P1SEL&=~0x01;            //Set Registers P1SEL & P1DIR to use P1_0 & P1_3 as outputs
        P1DIR|=0x01;
        P1SEL&=~0x08;
        P1DIR|=0x08;
        P1_0=0;                        //Switch On LED1 (Active to low level)
        EnableLEDs(3,TRUE);    //Switch On LED3 using function EnableLEDs
    }
    void  InitializeLEDs(BYTE LED)
    {
        switch(LED)
        {
            case 1:
                P1SEL&=~0x01;
                P1DIR|=0x01;
                break;
            case 3:
                P1SEL&=~0x08;
                P1DIR|=0x08;
                break;
      }
    }
    void  EnableLEDs(BYTE LED,BOOL On)
    {
        switch(LED)
        {
            case 1:
                LED1=!On;
                break;
            case 3:
                LED3=!On;
                break;
        }
    }
    

    With this coding way, LED1 switches on whereas LED3 remains OFF.

    But,… I have found why my initial program didn't work : indeed, within CodeBlocks Build Options, I have checked "Large Model Programs" and "Use a pseudo stack in the first 256bytes…" ! By unchecking these options, finally, the first program worked well !
    If you have any explanations on the fact that we should uncheck these options to have an operational program, I would be curious to know it.

    Moreover, I am thankfull for your help.

     
  • Maarten Brock
    Maarten Brock
    2010-05-11

    You might have found a bug then. The combination of -model-large and -xstack (with or without -stack-auto) is not part of our regression tests. IMHO it is a rare combination with suboptimal results.

     
  • Bissong
    Bissong
    2010-05-12

    Hi lostkeys911,
    I uses CC1110 with SDCC as well and never faced that kind of problem. Thus, all I can tell is the difference between your project and mine : I uses small model with "sdcc -c -xram-loc 0xF000 -code-loc 0x0000 -stack-auto" as command to compile. I hope this will help.
    G.