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.

problem setting Timer interrupt on CC430F6137

Other Parts Discussed in Thread: CC430F6137

Hello

I want one of my CC430F6137 (End device) sleep for 1 second in a low power mode and then send temperature data to the other CC430F6137 (which acts as Access point) using a timer interrupt. I tried to adapt the sample code and included Timer_A interrupt in my code. However, when I run it, the ISR is not called (not executed) at all. when I used breakpoints to debug, my program sleeps in the low power mode (sleeps at line:   __bis_SR_register(LPM3_bits +GIE);  )  and never wakes up and non of the rest of the code is executed. Please help if I am making a mistake with setting the timer_A interrupt. Thank you in advance.

Here is the main code I am using:

//main

void main (void)
{
  BSP_Init();
   /* Initialize TimerA and oscillator */
  UCSCTL4 |= SELA_1;                      // ACLK = VLO
  TA0CCTL0 = CCIE;                           // TACCR0 interrupt enabled
  TA0CCR0 = 12000;                           // ~ 1 sec
  TA0CTL = TASSEL_1 + MC_1;                  // ACLK, upmode

  /* Keep trying to join (a side effect of successful initialization) until
   * successful. Toggle LEDS to indicate that joining has not occurred.
   */
  while (SMPL_SUCCESS != SMPL_Init(0))
  {
    toggleLED(1);
    toggleLED(2);
    SPIN_ABOUT_A_SECOND;
  }
  /* Unconditional link to AP which is listening due to successful join. */
  linkTo();
  while (1) ;
}

static void linkTo()
{
  //uint8_t     msg[2];
 struct temperature value;
 uint8_t   misses, done;
  /* Keep trying to link... */
  while (SMPL_SUCCESS != SMPL_Link(&sLinkID1))
  {
    toggleLED(1);
    toggleLED(2);
    SPIN_ABOUT_A_SECOND;
  }
  /* put the radio to sleep... */
  SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_SLEEP, 0);

  while (1)
  {
     /* Go to sleep, waiting for interrupt every second to acquire data */
    __bis_SR_register(LPM3_bits +GIE);

    /* Time to read temperature */
    if (ReadSem)

      /* Set message ID */
      value.id = ++sTid;

      /* Get temperature */
      value.temp = get_temp ();
      
    /* get radio ready...awakens in idle state */
      SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_AWAKE, 0);

      done = 0;
      while (!done)
      {
        noAck = 0;

        /* Try sending message MISSES_IN_A_ROW times looking for ack */
        for (misses=0; misses < MISSES_IN_A_ROW; ++misses)
        {
          if (SMPL_SUCCESS == (rc=SMPL_SendOpt(sLinkID1, (uint8_t *)&value, sizeof(struct temperature), SMPL_TXOPTION_ACKREQ)))

          {
            /* Message acked. We're done. Toggle LED 1 to indicate ack received. */
            toggleLED(1);
            break;
          }
          if (SMPL_NO_ACK == rc)
          {
            /* Count ack failures. Could also fail becuase of CCA and
             * we don't want to scan in this case.
             */
            noAck++;
          }
        }
        if (MISSES_IN_A_ROW == noAck)
        {
          /* Message not acked. Toggle LED 2. */
          toggleLED(2);
#ifdef FREQUENCY_AGILITY
          /* Assume we're on the wrong channel so look for channel by
           * using the Ping to initiate a scan when it gets no reply. With
           * a successful ping try sending the message again. Otherwise,
           * for any error we get we will wait until the next button
           * press to try again.
           */
          if (SMPL_SUCCESS != SMPL_Ping(sLinkID1))
          {
            done = 1;
          }
#else
          done = 1;
#endif  /* FREQUENCY_AGILITY */
        }
        else
        {
          /* Got the ack or we don't care. We're done. */
          done = 1;
        }
      }
      /* radio back to sleep */
      SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_SLEEP, 0);

	  /* Done with measurement, disable read flag */
	   ReadSem = 0;
    }
  }
}

void toggleLED(uint8_t which)
{
  if (1 == which)
  {
    BSP_TOGGLE_LED1();
  }
  else if (2 == which)
  {
    BSP_TOGGLE_LED2();
  }
  return;
}
/*------------------------------------------------------------------------------
 * Timer A0 interrupt service routine
 *----------------------------------------------------------------------------*/

#pragma vector=TIMER0_A0_VECTOR
__interrupt void Timer_A (void)
{
  ReadSem = 1;
  __bic_SR_register_on_exit(LPM3_bits);        // Clear LPM3 bit from 0(SR)
}


**Attention** This is a public forum