This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Porting ZASA code to CCE

     Hi,

I'm doing a project using zasa code. I want to use cce compiler for that.

I have a problem with one identifier "istate_t". The error i'm gettin is "the identifier istate_t is undefined.

If i define it as a typedef unsigned short istate_t; linking fails. Can anyone help me?

  • Pandit Nad said:

    I'm doing a project using zasa code. I want to use cce compiler for that.

    I have a problem with one identifier "istate_t". The error i'm gettin is "the identifier istate_t is undefined.

    If i define it as a typedef unsigned short istate_t; linking fails. Can anyone help me?

    After going through the process of migrating the ZASA code to CCE, I see where you ran into the initial problem of the "istate_t" typedef issue.  I also added the typedef declaration in .\target\include\hal_types.h.
    At this point, there are a couple of modifications that are needed support a migration to CCE.  This is the treatment of interrupt service routines and how they are declared to the compiler and some inline assembly statements.

    You will need to modify the .\target\cc2480\hal_board.h in the following way.  Do not define __IAR_SYSTEMS_ICC__ for the CCE pre-processor build options.

    #ifdef __IAR_SYSTEMS_ICC__
    #define HAL_ENABLE_INTERRUPTS()         asm("eint")
    #define HAL_DISABLE_INTERRUPTS()        st( asm("dint"); asm("nop"); )
    #define HAL_INTERRUPTS_ARE_ENABLED()    (__get_SR_register() & GIE)
    #else
    #define HAL_ENABLE_INTERRUPTS()         _enable_interrupts()
    #define HAL_DISABLE_INTERRUPTS()        _disable_interrupts()
    #define HAL_INTERRUPTS_ARE_ENABLED()    (__get_SR_register() & GIE)
    #endif

     

    Secondly, you will need to modify the .\target\cc2480\hal_board.c in the following way.  Again, do not define __IAR_SYSTEMS_ICC__ for the CCE pre-processor build options.

    #ifdef __IAR_SYSTEMS_ICC__
    #define _PRAGMA(x) _Pragma(#x)
    #define HAL_ISR_FUNC_DECLARATION(f,v) _PRAGMA(vector=v) __interrupt void f(void)
    #define HAL_ISR_FUNC_PROTOTYPE(f,v)   _PRAGMA(vector=v) __interrupt void f(void)
    #define HAL_ISR_FUNCTION(f,v)         HAL_ISR_FUNC_PROTOTYPE(f,v); HAL_ISR_FUNC_DECLARATION(f,v)
    #else
    #define _PRAGMA(x) _Pragma(#x)
    #define HAL_ISR_FUNCTION(f,v)         _PRAGMA(vector=v) __interrupt void f(void)
    #endif

  • Thank u Brandon,

     I tried and modified little more thing and compiled without errors.

    Now i'm getting problem while running the program in halMcuInit() function.

    Tell me is there any things needs to change to make it work on CCE compiler.

    Thank u.

     

  • Where are you having issues?

    Have you stepped through halMcuInit() to determine where the issue occurring?

  • There's problem while executing low power mode,while stepping through that instuction it'll not show the pointer of PC.
    Also it's not acting as a co-ordinator. I'm not getting where the code is wrong. It'll not go appjoining state at all. It'll be there in appWaiting or appIniting state always. It'll keep on blinking the LEDs. Pls tell me where i went wrong.
     
    Thank u.
  • I'm not getting why it's not going to appWaiting state  and then to join after button press also.

    I'm not getting initially how it affects to zaccelstate and eventflags. Pls tell me where i'm wrong.

    Thanx.

  • Now halMcuInit() is executing. Problem is that it's responding to the button press.

    Also how halEventflags gets values for other states except HAL_EVT_BTN_PRESS?

    After executing this instruction halEventflags|=HAL_EVT_BTN_PRESS from port1 isr also it'll

    go to HAL_EVT_TIMER_LED state in appExecHal(void) function instead of going to HAL_EVT_BTN_PRESS event.

    This i have for that,

    uint16 appExecHal(void)
    {
      uint16 event = HAL_EVT_NONE;
     volatile halIntState_t s;

      if (halEventFlags & HAL_EVT_TIMER_LED)
      {
        event = HAL_EVT_TIMER_LED;
        appLedBlink(APP_STAT_LED);
      }
      else if (halEventFlags & HAL_EVT_TIMER_APP)
      {
        event = HAL_EVT_TIMER_APP;
        appExec();
      }
      else if (halEventFlags & HAL_EVT_TIMER_BTN)
      {
        event = HAL_EVT_TIMER_BTN;
        appBtnPress();
      }
      else if (halEventFlags & HAL_EVT_BTN_PRESS)
      {
        event = HAL_EVT_BTN_PRESS;

        halTimerSet(HAL_IDX_TIMER_BTN, APP_BTN_INTERVAL, 0);

        // Immediately turn of LEDs when user starts a join process.
        if (appState == appWaiting)
        {
          // Stop the LED blink during joining.
          halTimerSet(HAL_IDX_TIMER_LED, 0, 0);
          HAL_TURN_OFF_GRN();
          HAL_TURN_OFF_RED();
        }
      }
      else if (halEventFlags & HAL_EVT_ADC)
      {
        event = HAL_EVT_ADC;
        appSrceData();
      }
    #if HOST_MT
      else if (halEventFlags & HAL_EVT_MT_RX_RDY)
      {
        if (mtRx())
        {
          event = HAL_EVT_MT_RX_RDY;
        }
      }
    #endif
      else if (halEventFlags & HAL_EVT_NO_8MHz)
      {
        event = HAL_EVT_NO_8MHz;
      }

      /* Since HAL event flags are set at the interrupt level, they must only be cleared within
       * a critical section.
       */
      if (event != ZACCEL_EVT_NONE)
      {
        HAL_ENTER_CRITICAL_SECTION(s);
        event = halEventFlags & event;
        halEventFlags ^= event;
        HAL_EXIT_CRITICAL_SECTION(s);
        return TRUE;
      }

      return FALSE;
    }

    what's the  problem???

    Thank u.

     

  • Pandit said:

    Also how halEventflags gets values for other states except HAL_EVT_BTN_PRESS?

    The other event flags are defined in .\target\cc2480\hal_board.h.  Some of them are based on Software Timer Events that occur.  For example, HAL_EVT_TIMER_LED is mapped to HAL_EVT_TIMER0, which is a software timer event managed in .\target\cc2480\hal_board.c.  The variables used to drive the software timers are defined in hal_board.c as tmrTicks[] and tmrPeriod[].

     

    Pandit said:

    After executing this instruction halEventflags|=HAL_EVT_BTN_PRESS from port1 isr also it'll

    go to HAL_EVT_TIMER_LED state in appExecHal(void) function instead of going to HAL_EVT_BTN_PRESS event.

    If I place a breakpoint at the below location in sample_app.c in the appExecHal() routine, and I press the push button on the RF2480 Target board, the CPU will halt on that breakpoint.  This tells me, the HAL_EVT_BTN_PRESS is set and executed upon when a push button press occurs.

      else if (halEventFlags & HAL_EVT_BTN_PRESS)
      {
        event = HAL_EVT_BTN_PRESS;                                                       <<<< Set breakpoint here

        halTimerSet(HAL_IDX_TIMER_BTN, APP_BTN_INTERVAL, 0);

        // Immediately turn of LEDs when user starts a join process.
        if (appState == appWaiting)
        {
          // Stop the LED blink during joining.
          halTimerSet(HAL_IDX_TIMER_LED, 0, 0);
          HAL_TURN_OFF_GRN();
          HAL_TURN_OFF_RED();
        }
      }

    You can set a break point on the line of code by placing the cursor on that line, right-mouse click and select "Toggle Breakpoint".

  • Hi guys,

       I'm also interested in porting the ZASA code to CCE. Rather than reinvent the wheel, could either of you post your code to the forum or send it to me?

    Thanks,

    Derek

  • I hope to post updated code in a couple of days.  I have it running rather well.  I had it running on Rowley as well.

    I did make some changes though.  The sink now pumps out hex to the serial port rather than binary.  This makes it easy to debug changes with a simple terminal emulator.  I wrote a hack of a c# program to dump information to a datagrid.  Originally the sink pumped out binary, so I could not figure out changes to the message format.

    I have found, or think I have found, an issue with interrupts be handled by the ez430 HW.  Sometimes you start up the emulation and you end up sitting at one of the low_power mode calls, apparently waiting for an interrupt.  Looking at subsystem setups (i.e. timerA0 control registers), it appears that all the interrupt enable flags are set to generate interrupts.  Using the Rowley environment, simply disconnecting from the ez430 and then reconnecting gets the exact same code to run.  Before I identified this behavior, I kept thinking it was an error in my port of the code to CCE.  I changed more than a few things.  At some point the emulator would start working and I would think the last edit was the fix, which, in hind sight, was always incorrect.

    I am currently adding the light sensor to the message - on my way to build a remote rf tachometer.

  • Hello johno,

    How  you are testing for only SAPI commands response. I have written the code for hard reset and soft reset. Also i'm getting the response.

    But for loop back command in sys interface i'm not receiving the last byte of data what i'll send.

     Can you tell me where i'm wrong?? The code i have written is:

    #include"msp430x22x4.h"


    void ioinit(void)
    {
     
    //I/O Initialize

    //PORT1 INIT
        P1DIR = BIT0 | BIT1;   //0xFB;
        P1OUT = 0x00;
        P1SEL = 0x00;
       
    //PORT2 INIT:P2.6-SRDY(i/p)
         P2DIR = ~BIT6;
         P2OUT = 0xDD;
         P2SEL = 0x00;
        
    //PORT3 INIT:P3.0-STE,P3.6-MRDY,P3.7-RSTn  
         P3DIR = 0xFF;
         P3SEL = 0x00;
         P3OUT = 0x7F;
        
    //PORT4 INIT:P4.0-CFG0~Install 32khz crystal,P4.1-CFG1~Select SPI Operation
       P4DIR = 0x03;
         P4OUT = 0x03;
         P4SEL = 0x00;
    }
     
    void main(void)
    {
     
        WDTCTL = WDTPW + WDTHOLD;
     
     BCSCTL1 = CALBC1_1MHZ;                    // Set DCO
        DCOCTL = CALDCO_1MHZ;
       
        ioinit();
        spiinit();
        sysreset();
    }

    #include"msp430x22x4.h"
    #include "spi.h"

    #define RST_Clr()       (P3OUT |= BV(7))
    #define RST_Set()       (P3OUT &= ~BV(7))
    #define SRDY()          (((P2IN & BV(6)) == 0))
    #define SRDY_RSP()  (!SRDY())
    unsigned char string[256];
    unsigned char *pBuf = string;

     

    void spiinit(void)
    {
     UCB0CTL1 = UCSWRST;//Held spi reset till initialize all spi reg's
        UCB0CTL0 = UCCKPH | UCMSB | UCMST | UCSYNC | UCMODE_0;  //UCCKPH |
        UCB0CTL1 |= UCSSEL_2;   //SMCLK
        UCB0BR0 = 0x01;        
        UCB0BR1 = 0x00;
        P3SEL |= 0x0E;         //Select MISO,SOMI,UCLK for spi operation
        UCB0CTL1 &= ~UCSWRST;  //Start spi operation
        IE2 |= UCB0TXIE | UCB0RXIE; // Enable interrupts
       
    }

    void sysreset(void)
    {
     //uint16 i=0;
     RST_Set();
     delay(10);
     RST_Clr();
     delay1();//Delay for 250msecs
     while (!SRDY());  //Wait until cc2480 comes out of reset

     spiPOLL(pBuf);
    }

    void delay(uint16 msecs)
    {
     uint16 count=0;
     TACTL &= ~MC_1; //stop the timer
     count = msecs*1000;
     
     TACCR0 = count;
     TACCTL0 = CCIE;
     TACTL =  TASSEL_2 + MC_1;
     while(TAR != TACCR0);
       while(!(TACCTL0 &= CCIFG));
     
    }


    void delay1(void)
    {
     uint16 i=25;
     
     while(i--)
     {
      delay(10);
     }
     
    }

    void spiwrite(uint8 *pBuf,uint8 len)
    {
     uint16 i=0;
      SS_Set(); //P3OUT &= ~BIT0;
        while (len--)
        {
          UCB0TXBUF = *pBuf;
          while (!(IFG2 & UCB0RXIFG));
          *pBuf++ = UCB0RXBUF;
          P1OUT ^= 0x01;
          for(i=50000;i>0;i--);
        }
       SS_Clr();// P3OUT = BIT0;

    }

    void spiSREQ(uint8 *pBuf)
    {
     //uint16 i=0;
     do
     {
      getSRDY1();
      spiwrite(pBuf,3);
        //If SRDY is not high poll again
        *(pBuf+0)=0x00;  //data length 0
        *(pBuf+1)=0x00;  //cmd0
        *(pBuf+2)=0x00;  //cmd1
     } while(!getSRDY2()); 

       P1OUT = 0x02;// STARTS RX DATA.
       spiwrite(pBuf,3);
       if(*pBuf != 0)
       {
        spiwrite(pBuf+3,*pBuf);
       }
      
       MRDY_Clr();   //P3OUT |= 0x40;   //Set MRDY high
    }

    void spiPOLL(uint8 *pBuf)
    {
     MRDY_Set(); //P3OUT &= ~0x40;  //Set MRDY low
     
        //Poll command
        *(pBuf+0)=0x00;  //data length 0
        *(pBuf+1)=0x00;  //cmd0
        *(pBuf+2)=0x00;  //cmd1
        
         spiSREQ(pBuf);
    }


    void getSRDY1(void)
    {
     MRDY_Set();   //P3OUT &= ~0x40;//MRDY Low
     delay(10);  //SRDY_WAIT_MSECS=10
     
      if (!SRDY())
      {
        MRDY_Clr(); //P3OUT |= 0x40;  // Set MRDY high
        sysreset();
        MRDY_Set(); //P3OUT &= ~0x40; //// Set MRDY low before talking to slave
      }

    }

    uint8 getSRDY2(void)
    {
        delay(10);
        return SRDY_RSP();
    }

     

  • I think bcoz of that problem itself i'm not getting the correct response for CONFIGURATION INTERFACE commands.

    I tried for zb_writeconfiguration and also z_readconfiguration. I'll get the response problem is that, if i change the LOGICAL VALUE  and configure.

    If read it back i'm getting 0x00 only . So i'm thinking that might be it's because of TX/RX problem as i found in SYS loop back command.

  • Hi Jono,

    Some time ago you promissed to post update code for the ZASA port to CCE. I'm working on that to. I have ported the code using the ideas on this site, but do not get a system that is working flawless. I'm not quite sure what's wrong, but i assume thera zome timing problems in sending messages via spi and receiving the answer. If  you did manage to create a stable system whould you share your code with me?

     

  • nsinkrten,

    Where did the last month go?  I have ported the code to CCE and Rowley.  I am currently wrestling with Rowley over a single line in one of their header files.  I am liking Rowley.

    I changed the serial interface to the application; requiring a new C# program to read the data.  The one supplied by TI is very pleasing to the eye at conferences, but it does not let you see the messages.

    I will try to post the code this weekend.  The actual number of lines that change are just a handful.

    I have found that the ez430 emulation does not seem to be repeatable.  Sometimes:

    1) Global variables that should be initialized to zero, are not.

    2) With appropriate interrupts enabled, interrupts do not occur

    3) IAR, TI and Rowley define intrinsics basically the same, but you need to look at the dissassembled code to confirm.

    4) Jumping from one emulator to another may cause the above issues

    5) The above issues can be fixed, usually, by closing all IDEs, cycling power to the ez430.

    With the above five issues, you can start a new debug session, following a debug session that was working, make a few changes, have the emulation not work, and think it was your last edit.  Then you cycle power to the ez430 and Voila! it works.  Same exact code.  Once you get the ez430 emulating, it seems to be stable for multiple edit->dowload->emulate cycles.

    I have no time to review your code, sorry.

    John

  • I added two zip files to my file area.  One holds modified ez430-RF2480 target code.  The changes include:

    1) Port to CCE 3.1

    2) Port to Rowley 2.0

    3) Support for the light sensor (Thanks to johnw for some of the code)

    4) Output is in hex, so one can look at the messages on a terminal editor, but this breaks the TI supplied sensor monitor.

    The target code compiles under IAR, but is over the 4K limit.  If anybody with a full IAR license would be so kind as to compile and verify that it runs, I would appreciate it.

    To get Rowley to work, you need to change their inmsp.h to this definition

    #define __low_power_mode_off_on_exit() __bic_SR_register_on_exit(0xF0)

    (I am liking Rowley.)

    I also included C# code using Visual C# 2008 Express.  It handles the hex output  mentioned above.  Initially it is anotating the message stream, such that I may start getting a sense for the SAPI message flow.

     

     

  • Hi John,

     

    Thanks for posting your code for the eZ430-RF2480 application. I have installed it and experimented with it. I have the same problem with your code as I had with my attempt to port the code to CCE. It happens rather often that a node does not get the right network state (zaccelNwkState) after starting the stack. If, for example, the node is started as a router, the green led should be continuously on and the red led only when data is sent. But often both the red and green leds blink in the same frequency. In the Sensor Monitor however, the node shows up as a router. Using the debugger I see that zaccelNwkState has still the value DEV_HOLD. The only reason I can think of for this is, that the zb_GetDeviceInfoConfirm() call is missed. Until now I'm not able to find out why. Didn't you experience this problem?

    Onother problem is that it is very difficult to generate only one button push, but this may be due to rickety buttons.

    Regards,

    Marten

  • Hi all,

    I have written a code for SPI transport using ez430-RF2480. My goal is port whole zasa code to work it on CCEv3.

    Initially i'm trying to get response for al commands, then i want go for application progarm.

    Now i'm getting a response for hard reset and other SREQ commands of SYS interface. Also i tested  for some SAPI commands and Configuration Interface commands.

    Now problem is that i'm not getting a response for some commands that i mentioned below, pls anyone can help me a bit:

    1) For loop back command in SYS interface i'm not getting a complete frame what i'll send. Only i  have a problem with last byte reception. What'll be the cause???

    2) In CFG interface: to test read and write configuration i did in this way:

            1st i have written STARTUP_OPTION  with =0x02;

      next   i'll read default value LOGICAL TYPE(i'll get 0x00)

    Then i'll change the LOGICAL TYPE by sending the new value in Write configuration command (i changed to 0x02)

    For all these i'll get SRSP.

    After this if i read LOGICAL TYPE using Read configuration i should get the new value. But it's receving  the default value.

    what's the problem??

    Is there any other steps to follow for this???

     

    3) Also after sending whole AREQ frame from host processor , chip is not pulling SRDY HIGH. I tested it for (SYS_RESET_REQ Command).

    What'll be the cause???

     

    Here are some functions what i'll use:

    #include<msp430x22x4.h>
    #include "spi.h"

    #define RST_Clr()       (P3OUT |= BV(7))
    #define RST_Set()       (P3OUT &= ~BV(7))
    #define SRDY()          (((P2IN & BV(6)) == 0))
    #define SRDY_RSP()  (!SRDY())
    unsigned char txBuf[256];
    unsigned char rxBuf[256];
    unsigned char *pBuf = txBuf;
    unsigned char *pBuf1 = rxBuf;

    void  getSRDY(void);
    void  getSRDY1(void);
    uint8 getSRDY2(void);

    void sysreset(void)
    {
     RST_Set();
     delay(10);
     RST_Clr();
     delay(250);//Delay for 250msecs
     while (!SRDY());  //Wait until cc2480 comes out of reset
     
     spiPOLL(pBuf);
    }

    void softreset(void)
    {
     //SYS_RESET_REQ command
     *(pBuf+0)=0x01;  //data length
        *(pBuf+1)=0x41;  //cmd0
        *(pBuf+2)=0x00;  //cmd1
        //Data
        *(pBuf+3)=0x00;
       
        spiAREQ(pBuf);
       
        P3OUT = 0xFF;
        P1OUT = 0x01;
       
        spiPOLL(pBuf);
       
        P1OUT = 0x02;
    }

    void syscmds(void)
    {
     //sys version cmd
      *(pBuf+0)  = 0x00;//length
      *(pBuf+1) = 0x21;//cmd0
      *(pBuf+2) = 0x02;//cmd1
     
        spiSREQ(pBuf);
       
    }

     
     


    void spiwrite(uint8 *pBuf,uint8 len)
    {
        while (len--)
        {
          UCB0TXBUF = *pBuf;
          while (!(IFG2 & UCB0TXIFG));
          pBuf++;
        }
    }

    void spiread(uint8 *pBuf1,uint8 len)
    {
        while (len)
        {
           UCB0TXBUF = *pBuf1;
           while (!(IFG2 & UCB0RXIFG));
          *pBuf1++ = UCB0RXBUF;
           len--;
        } 
    }


    void spiSREQ(uint8 *pBuf)
    {
     uint16 l;
     
     do
     {
      getSRDY1();
      spiwrite(pBuf,(*pBuf+3));
      //while(SRDY());
        //If SRDY is not high poll again
        *(pBuf+0)=0x00;  //data length 0
        *(pBuf+1)=0x00;  //cmd0
        *(pBuf+2)=0x00;  //cmd1
     }while(!getSRDY2()); 

       // STARTS RX DATA.
       spiread(pBuf1,3);
       if(*pBuf1 != 0)
       {
        l = *pBuf1;
      
        spiread(pBuf1+3,l);
       }
      
       MRDY_Clr();   //P3OUT |= 0x40;   //Set MRDY high
     
    }


    void spiAREQ(uint8 *pBuf)
    {
     uint16 i=0;
     
     do{
        getSRDY1();
        
         for(i=50000;i>0;i--);
          P1OUT ^= 0x01;
      
        spiwrite(pBuf,4);   //(*pBuf+3)
        
        }while(!getSRDY2());
       // while(!getSRDY2());

           /* for(;;){
          for(i=50000;i>0;i--);
       P1OUT ^= 0x01;}*/

      
       MRDY_Clr();
      
    }


    void spiPOLL(uint8 *pBuf)
    {
     uint16 l=0;
      // Setup the POLL command in the buffer.
      *(pBuf+0) = 0;    // DATA LENGTH
      *(pBuf+1) = 0;    // CMD0
      *(pBuf+2) = 0;   // CMD1
     
     do
     {
      getSRDY();
      spiwrite(pBuf,3);
        //If SRDY is not high poll again
        *(pBuf+0)=0x00;  //data length 0
        *(pBuf+1)=0x00;  //cmd0
        *(pBuf+2)=0x00;  //cmd1
       
     }while(!getSRDY2()); 

       // STARTS RX DATA.
       spiread(pBuf1,3);
       if(*pBuf1 != 0)
       {
        l = *pBuf1;
        spiread(pBuf1+3,l);
       }
      
       MRDY_Clr();   //P3OUT |= 0x40;   //Set MRDY high
    }


    void delay(uint16 msecs)
    {
     uint16 count=0;
      while(msecs--)
        {
           count = 1000;
        while(count--)//1msec=1000usec
        {
         _nop();   //1us, clk 1Mhz
        }  
        }
     
    }


    void  getSRDY(void)
    {
     while (!SRDY());  //Does CC2480 has a AREQ command to send?? If so send a POLL
        MRDY_Set();  //MRDY Low

     delay(10);  //SRDY_WAIT_MSECS=10
     
      if(!SRDY())
      {
        MRDY_Clr();    // Set MRDY high
        sysreset();
        MRDY_Set();   // Set MRDY low before talking to slave
      }
    }

    void  getSRDY1(void)
    {
        MRDY_Set();  //MRDY Low
        while (!SRDY());
     delay(10);  //SRDY_WAIT_MSECS=10
     
      if(!SRDY())
      {
        MRDY_Clr();    // Set MRDY high
        sysreset();
        MRDY_Set();   // Set MRDY low before talking to slave
      }
    }

    uint8 getSRDY2(void)
    {
        delay(10);
        return SRDY_RSP();
    }

     

    Thanks!!

     

     

     

  • Marten,

    You appear to be farther into understanding ZASA, etc than I am.  I barely have looked at the ZIGBEE protocol and have little understanding of the specifics of routers, sinks, etc.  All I can say is that the code I have played with is sometimes goofy in the debugger.  Close the debugger, cycle power to the unit having bizarre behavior and that same code behaves as expected.  My favorite example was setting a break point at the first statement in main() and looking at some of the variables that were not explicitly initialized (should be initialized to zero) and finding those variables at a non-zero value.  Those variables were the system state variables.  This trick was repeatable once, then I have never seen it since (I also explicitly initialize all globals, but that should not matter.)

    I am a hobbyist as far as the MSP430 goes.  (At work I program AVRs, embedded x86 and c#.)  My next step is comparing CCE to Rowley.  I get excited about eclipse every now and then.  Then I use it and, for embedded products, there just seems to be so many quirks, that it ends up being a very expensive free product.  A developer on Linux may like CCE, but as a Visual Studio regular, Rowley feels better.

    Good luck

  • Dear Johno

     

    I have tried to download and use your port to CCE of ZASA.

     

    I open the project and when I compile it gives me an error that hal_board.h is referring to a file msp430.h that does not exist. I have tried to find this file and it is not within the port.

    Could you please be so kind to help me?

     

    Best Regards

     

    Rcravaja

  • rcravaja said:

    I open the project and when I compile it gives me an error that hal_board.h is referring to a file msp430.h that does not exist. I have tried to find this file and it is not within the port.

    The msp430.h file should be part of your Code Composer Essentials installation which may be in a different path than what is on Johno's system.  You may need to adjust the include paths for the compiler and linker to point to the appropriate location on your system.

  • Thank you very much brandon

     

    I cannot find this file inside my file system. That's why I am confused. I cannot modify the path as the file is not in any directory of the CCE instalation.

     

    Could you please tell me where do you have it in you file system?

     

     

    best Regards

     

    Ramon

     

  • Below is the path to the msp430.h on my system.  I have installed the CCE v3.1 version as well as the MSP430 code generation tools v3.1.

    C:\Program Files\Texas Instruments\CC Essentials v3\tools\compiler\MSP430_31\include

     

  •  BrandonAzbell,

    I have written the code for Tx (router) and Rx(Co-ordinator). I have written the code in the following way:

    //Common for  Co-Ordinator & Router program

      ioInit();
      halMcuInit();
      halSPIInit();

    Co-Ordinator:

    I'll send the follwing commands in the same sequence:

    SYS_RESET_REQ  //I'll receive reset indication

    ZCD_NV_STARTUP_OPTION //After i'll receive SRSP then i'll reset to take it's effect


    As default logical value ll be 0x00 (Co-Ordinator), I have not written logical type again. But i have tested by zb_readconfiguration.

    I have written the PAN ID= 0x3FFE //This is same for both devices. After this i'm sending sapi commands.

    zb_SapiAppRegister();


    zb_StartRequest();


    zb_PermitJoiningRequest();


    zb_AllowBind();// I'm keeping the co-ordinator in AllowBinding mode  Indefinetely

    I'm getting correct SRSP for all commands and start confirm with status as 0x00(zsucces).

    After cofiguring all these things i thought co-ordinator is ready to receive data, so i have written follwing code for receiving.

    while(1)        //Read continuously if has  a data.

    {
        while(!SRDY());
         if(SRDY())
       { 
         P1OUT = BIT0; //RED LED CO-ORDINATOR
         zaccelPoll();
       } 

         P1OUT |= BIT1;  //DATA RXD, BLINK GREEN LED
        for(i=50000;i>0;i--);
        P1OUT |= ~BIT1;

     }

    For ROUTER i did in the following way:

    SYS_RESET_REQ //I'll receive reset indication

    ZCD_NV_STARTUP_OPTION //After i'll receive SRSP then i'll reset to take it's effect

    zb_writeLogicalType// i'm setting it as a router(0x01). After i'll receive SRSP then i'll reset to take it's effect.

    To make sure the logical type i have read it using zb_ReadConfiguration(), it's correct.

    I'm setting here PAN ID to the same value as for co-ordinator. Then i'm sending SAPI commands,

    zb_SapiAppRegister(); //i'll receive correct SRSP

     

    zb_StartRequest(); //i'll receive correct SRSP also start confirm

     

    zb_BindDevice(); // Here i'm getting correct SRSP but in confirm callback status byte is 0x21 it's of no meaning in status values list. What's the problem??

    After this i'm sending a data continuously using SEND_DATA_REQUEST command like this below:

     while(1){

     P1OUT = BIT1;//GREEN LED-ROUTER
         
       zb_SendDataRequest();
     
          P1OUT = BIT0;    //DATA SENT, RED LED
        for(i=50000;i>0;i--);
          P1OUT = ~BIT0;

    }

    As bind confirm status is wrong,so i think i'm receving any data. But dont know how i'm getting correct SEND_DATA_CONFIRM callback with status 0x00.

    Is the way i did is correct? If not pls tell me how to it for the Tx and Rx functioning by making Co-ordinator and router.

    Thanks for any help.

    Also i Apologize for the big post.  Any way pls tell me how to make for Tx/Rx by making logical Device??

    Thank u.

     

     

  • I have learnt so many things from u. Let me learn about SAPI also.[:D]

    How , is it possible to know the no of nodes(routers or end devices) joined to the co-ordinator?? As there is no command for this, am i right?

    First let me know what all things needs to done before sending a data using send data request. Questions are simple. Just i want make sure that i'm in right way or not.

    Please.

    Thank u.

  • Hi folks,

    This might help others who pass by here trying to port ZASA to CCS v4.0.2 (maybe other versions, but that's what I'm using). I made the changes as suggested by Brandon, and finaly got it compiling (hurrah!). Once it was running, though, I couldn't get it to become a coordinator, router or sink, or indeed, do anything on the zigbee side. I stepped through the code in debug and found that it didn't matter what I did, it would always return TRUE from appHalExec(), whether or not any HAL events had been triggered. When stepping one line at a time, I found it would reach   the line if (event != HAL_EVT_NONE), skip all the lines under that if condition (which it should, as event == HAL_EVT_NONE), but grab the "return TRUE". I have seen this before - some C compilers can't handle multiple return statements in a function, and will always execute the first one found, whether or not its insid an if. To correct this, I added

    uint16 returnval = FALSE;

    at the top of the appExecHal() and appExecHost() (which has the same issue), then replaced the "return TRUE;" with "returnval=TRUE;" and then replaced the "return FALSE;" with "return returnval;" at the bottom of the function. Since I did this, the ZASA code runs fine and I've been able to start adding my application code over the top.

    Turns out my embedded systems lecturer wasn't mucking us about when he said to always use a variable to hold return values, rather than switched return statements.

     

    good luck,

    -Iain