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.

Timer Interrupts with SimpliciTI

Other Parts Discussed in Thread: SIMPLICITI, CC2500, MSP430FG4618

I'm just trying to develop an application on the MSP-EXP430FG4618 to carry out some processing every 5 ms, and transmit  a resultant number of bytes using SimpliciTI, and a CC2500 radio.

Before the wireless functionality was required,the processing was initiated using a timer interrupt on Timer A.

I understand that Timer A has some relationship with SimpliciTI and so I tried switching to Timer B to preform the interrupt and to call the transmission function.

Separately, both functions worked perfectly. Wireless transmission was working fine as a stand-alone program and the processing program had no issues before the transmission function was introduced.

The program works fine for a few seconds initially, and then appears to crash and enter disassembly in debug mode.

I can't seem to find the source of this problem.

Is there some particular way of performing timer interrupts if one intends to use SimpliciTI?

The start of the code is included below:-

void main(void)
{    

      WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
      BSP_Init();


#ifdef I_WANT_TO_CHANGE_DEFAULT_ROM_DEVICE_ADDRESS_PSEUDO_CODE
  {
    addr_t lAddr;

    createRandomAddress(&lAddr);
    SMPL_Ioctl(IOCTL_OBJ_ADDR, IOCTL_ACT_SET, &lAddr);
  }
#endif

  while (SMPL_SUCCESS != SMPL_Init(sCB))
  {
    toggleLED(1);
    toggleLED(2);
    SPIN_ABOUT_A_SECOND; //1 Second Delay -- Remove
  }

         SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_AWAKE, 0);

          
          
    
  TBCCR0 = 5000;                           // Delay to allow Ref to settle
  TBCCTL0 = CCIE;   
  TBCTL = TBSSEL_2 + MC_2;                  // SMCLK, contmode

  __bis_SR_register(LPM0_bits + GIE);       // Enter LPM0, enable interrupts

 

The rest of the program continues after the interrupt but fails shortly afterwards.

I've tried numerous variations of the above but nothing seems to work.

 

  • Hello.

    Using a separate timer should be OK in theory. This is likely not the problem.

    The SimpliciTI code is not thread safe. If your timer interrupt causes multiple concurrent Tx threads to occur it will likely not work correctly. You might try a couple of experiments. Does the device work correctly if you increase the 5 ms timer interval? You also might try putting a reentry check in the Tx thread to see if you are inadvertently trying to instantiate multiple concurrent Tx threads.

    If you truly need independent Tx threads (e.g., multiple independent applications requiring the Tx capability) it will not work by direct invocation. You'd need to design a method that guarantees a single Tx thread at a time such as a job queue or some other guaranteed single-server scheme.

    Hope this helps.

    lfriedman

     

  • Hi,

    Thanks very much for the reply.

     

    --edit-- It appears to have been a battery issue. Working fine now.

     

     

     

     

    I'm afraid I'm still having problems, but I've made things far simpler just to find out what the issue is.

    Basically when the following line is uncommented, the program crashes. When it's commented out, the program runs fine:-

       SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_AWAKE, 0);   //CAUSES CRASH WHEN UNCOMMENTED

    Do you know why this might be the case?

    I'm confused as I can't see why simply waking the radio would cause a complete crash to occur.

    I though that maybe removing interrupts until after the SimpliciTI initialisation was complete would help, but the success of the program appears to be entirely dependant on the RADIO_AWAKE line.

    I've included the entire code below:-

    It's a modification of the timer B sample program for the MSP430FG4618.


    void main (void)
    {     
        volatile unsigned int i;
      WDTCTL = WDTPW+WDTHOLD;                   // Stop WDT
      FLL_CTL0 |= XCAP14PF;                     // Configure load caps
      // Wait for xtal to stabilize
      do
      {
      IFG1 &= ~OFIFG;                           // Clear OSCFault flag
      for (i = 0x47FF; i > 0; i--);             // Time for flag to set
      }
      while ((IFG1 & OFIFG));                   // OSCFault flag still set?
      TBCCTL0 = CCIE;                           // TBCCR0 interrupt enabled
      TBCCR0 = 50000;                           //
      TBCTL = TBSSEL_2+MC_2;                    // SMCLK, continuous mode
      _BIS_SR(LPM0_bits + GIE);                 // CPU off, interrupts enabled



    //SIMPLICITI INITIALISATION


      BSP_Init();

    #ifdef I_WANT_TO_CHANGE_DEFAULT_ROM_DEVICE_ADDRESS_PSEUDO_CODE
      {
        addr_t lAddr;

        createRandomAddress(&lAddr);
        SMPL_Ioctl(IOCTL_OBJ_ADDR, IOCTL_ACT_SET, &lAddr);
      }
    #endif

      while (SMPL_SUCCESS != SMPL_Init(sCB))
      {
        toggleLED(1);
        toggleLED(2);
        SPIN_ABOUT_A_SECOND; //1 Second Delay -- Remove
      }
     
     
     
       SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_AWAKE, 0);      //CAUSES CRASH WHEN UNCOMMENTED


      while(1){
      test=0;
      }
     
    }

     


    // Timer_B interrupt service routine -- Toggle P5.1
    #pragma vector=TIMERB0_VECTOR
    __interrupt void Timer_B (void)
    {
      P5OUT ^= 0x02;                            // Toggle P5.1
      TBCCR0 += 50000;                          // Add Offset to TACCR0
    __bic_SR_register_on_exit(LPM0_bits);     // Exit LPMx, interrupts enabled
    }

     

    void toggleLED(uint8_t which)
    {
      if (1 == which)
      {
        BSP_TOGGLE_LED1();
      }
      else if (2 == which)
      {
        BSP_TOGGLE_LED2();
      }
      return;
    }


    static uint8_t sCB(linkID_t lid)
    {
      if (lid == sLinkID1)
      {
        sPeerFrameSem++;
        return 0;
      }

      return 1;
    }