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.

some cc1110 board cannot work on pm2 with tx/rx

Hi,

      I really need your help.

     We'v made 12K CC1110 board.  This boards all can work on PM0 with TX/RX,  over 60 percent can work on PM2 with TX/RX. and yesterday, I use IAR to debug one of the board online , try to find the issue, not found it, but after I flash it with hex file to work in PM2 with TX/RX, it also can work now.   but not repeat on the another board. It's really bother me.

     And it's time to deliver this boards to customer, could you give us a help? 

    Thanks much indeed!

          

  • Hi,

        Could you take a little time, to give me some advice?  or any other information should I post?

        Thanks!

  • Unfortunately it is not possible to help you when the only info we have is that you are using CC1110 and PM2 and something is not working. To be able to help you we need a lot more info about what you are doing in your code and how is it failing.

    I assume you have followed the errata note on how to enter PM2.

    What are the problems you are seeing?

    Are you not entering PM2? (how do you know?)

    Are you not waking up from PM2? (how do you know?)

    Is it TX or RX that are failing (how do you know?)

    Siri

  • hi, Siri:

    Thanks very much for your reply.

    Yes, Our code to enter PM2 followed the DN106.

    The problem We can see: when the code runs in PM0(just comment the statement of enter PM2, instead of the line of : halWait() call), all works fine. but when works on PM2, just over 60 percent can work, and others looks hang or dead.

    Other information, could you take a while to check our code list below: thanks!

    Here is the demonstration of the code:

    void main ()
    {
        SET_32KHZ_CLOCK_SOURCE(RC);        
        SET_MAIN_CLOCK_SOURCE(CRYSTAL);     
    
        halWait(200);                        
        
        InitIoInput();        ///init port             
    
        halWait(200);        ////delay
      
        WDT_ENABLE();
    
        
        LoadFlashInfo();    ///load flash info
    
        radioInit( myAddress ); ///rf init
    
        INT_GLOBAL_ENABLE(INT_ON);
    
        halInitSleepTimer();     
    
        while (TRUE)
        {
        	int flag = ReadI2C(); ///read info from I2C
        	
        	if (flag)
        	{
        	  radioInit( myAddress );
        	  TX_to_sendInfo(); ///went TX mode to send Info.
        	}
        	else
        	{
        	  radioInit( myAddress );
        	  Rcv_data();       ///went RX mode to rcv info
        	}
        	
        	setSleepTimerPeriod(100,MILLISECOND);    
          halResetSleepTimerAndEnterPM2();  
          
          if (received info){radioInit( myAddress );TX_to_SendAckInfo(); }  ///chk received info, and send ack .
          
          WDT_RESET(); ///feed dog
         }
    }
    
    
    void halInitSleepTimer(void)
    {
      SleepDMAInit(); ///
    
      INT_GLOBAL_ENABLE(INT_OFF);      
      SLEEP_TIMER_INIT();
      INT_SETFLAG(INUM_ST,INT_CLR);
    
      INT_ENABLE(INUM_ST,INT_ON);
      SLEEP_TIMER_ENABLE_EVENT0_INT(INT_ON);
      INT_GLOBAL_ENABLE(INT_ON);
    }
    
    BYTE setSleepTimerPeriod(WORD time, TimeUnit_def uintV)
    {
      UINT32 temp = 0;
      BYTE wor_res = 0;
      float temp2;
      if( (uintV == MILLISECOND) && (time < 12) )return 3;
    
      if (!(CLKCON & 0x80))  SET_32KHZ_CLOCK_SOURCE(RC);         
    
      if(CLKCON & 0x80)                                  
      {
        if( (uintV == HOUR) && (time > 17) )return 2;    
        temp2 = time * 104000 / 3;                       
      }
      else
      {
        if( (uintV == HOUR) && (time > 18) )return 2;     
        temp2 = time * 32768;
      }
    
      if(uintV == MILLISECOND)
      {
        temp2 /= 1000;
      }
      else
      {
        while(uintV > SECOND)                            
        {
          temp2 *= 60;
          uintV --;
        }
      }
      temp = (UINT32)temp2;
      while(temp > 0xffff)
      {
        temp >>= 5;
        wor_res ++;
      }
    
      WORCTL &= ~0X03;
      WOREVT1 = (BYTE)((WORD)temp>>8);
      WOREVT0 = (BYTE)((WORD)temp);
      WORCTL |= wor_res;
    
      return 0;                                           //on success, return 0
    }
    
    
    void  SET_POWER_MODE2(void)
    {
        SLEEP &= ~0x1B;
        SLEEP |= 2;
    
        {
            char temp = WORTIME0;
            while(temp == WORTIME0);
        }
    
        MEMCTR |= 0x02;
        SLEEP = 0x06;
    
        asm("NOP");
        asm("NOP");
        asm("NOP");
        if(SLEEP & 0x03)
        {
            asm("MOV 0xD7,#0x01");  // DMAREQ = 0x01;
            asm("NOP");  // Needed to perfectly align the DMA transfer.
            asm("ORL 0x87,#0x01"); // PCON |= 0x01;
            asm("NOP");
        }
        MEMCTR &= ~0x02;
    }
    
    void halResetSleepTimerAndEnterPM2(void)
    {
      BYTE temp;
      SLEEP_TIMER_RESET();
      WORIRQ &= ~0X01;
      temp = WORTIME0;
      while(temp == WORTIME0);
      temp = WORTIME0;
      while(temp == WORTIME0);                            ///
      INT_SETFLAG(INUM_ST,INT_CLR);
    
      SET_POWER_MODE2();
    
    }
    
    #pragma vector = ST_VECTOR
     __interrupt void ST_ISR(void)
    {
      INT_SETFLAG(INUM_ST,INT_CLR);
      WORIRQ &= ~0X01;
      SLEEP  &= ~0x03;
      return;
    }
    
    
    
    #pragma vector=RF_VECTOR
    __interrupt void spp_rf_IRQ(void)
    {
       BYTE enabledAndActiveInterrupt;
    
       INT_GLOBAL_ENABLE(INT_OFF);
       enabledAndActiveInterrupt = RFIF;
       RFIF = 0x00;                        // Clear all interrupt flags
       INT_SETFLAG(INUM_RF, INT_CLR);    // Clear MCU interrupt flag
       enabledAndActiveInterrupt &= RFIM;
    
       // Start of frame delimiter (SFD)
       if(enabledAndActiveInterrupt & IRQ_SFD)
       {
          if(sppRxStatus == RX_WAIT)
          {
             sppRxStatus = RX_IN_PROGRESS;
             RFIM &= ~IRQ_SFD;
          }
       }
    
       // Transmission of a packet is finished. Enabling reception of ACK if required.
       if(enabledAndActiveInterrupt & IRQ_DONE)
       {
          if(sppTxStatus == TX_IN_PROGRESS)
          {
             if(pAckData == NULL)
             {
                sppTxStatus = TX_SUCCESSFUL;
             }
             else
             {
                DMA_ARM_CHANNEL(dmaNumberRx);
             }
          }
    
          // Clearing the tx done interrupt enable
          RFIM &= ~IRQ_DONE;
    
       }
       INT_GLOBAL_ENABLE(INT_ON);
    }
    

  • Hi

    In the function setSleepTimerPeriod, the updating of EVENT0 should be align to a positive edge on the 32 kHz clock source (see p. 127 of the data sheet).

    You must also make sure that he radio is running at the HS RC oscillator with the highest clock speed setting possible when entering PM2 and then you need to turn on again the crystal when waking up before using the radio. This is explained in the errata note.

    I cannot see that you are setting up and arming the DMA either, as explained in the errata. To me it looks like you have only implemented half of the work-around described. The code in blue font in the errata is not the only code you must implement, it is the only code that must be implemented without any intervening code. The rest of the code must also be included.

    When turning on the crystal, please take into account the issue described in the errata note regarding the premature XOSC_STB assertion.

    Siri

  • Hi,Siri:

       Thanks,  your reply helps, I'll  test more.

       Wish you have a good day!

       :)

  • Hi, Siri:

        Sorry to bother you again, I think I'm too optimistic on this issue, I need your help again, please give me hand, thakds.

        After added the code, the boards can up, but a few days test,  I suddenly find the Sleep time was incorrect, whatever how long I want it in PM2, it just past by, so it "waked",  in another words, It cannot work properly in PM2.

         Our board don`t has a 32K crystal oscillator on it. We just add a external 26M crystal oscillator on the board.

         And I found this code:

    ////////////////////////////////////////////////
        // Errata approach: switch to HS RCOSC
        // make sure HS RCOSC is running at highest speed, i.e. 24MHz
        ////////////////////////////////////////////////
        SLEEP &= ~0x04; // power up both osc, SLEEP.OSC_PD = 0
        while (!(SLEEP & 0x20)); // wait until HS RCOSC is stable, SLEEP.HFRC_STB = 1
        CLKCON = (CLKCON & ~0x07) | 0x40 | 0x01; // switch to HS RCOSC CLKCON.OSC = 1, set max CPU clock speed CLKCON.CLKSPD = 1
        while (!(CLKCON & 0x40)); // wait until system clock is actually changed CLKCON.OSC = 1
        SLEEP |= 0x04; // power down unused osc, HS XOSC, SLEEP.OSC_PD = 1 
        ////////////////////////////////////////////////
        // Errata approach: switch to HS RCOSC
        ////////////////////////////////////////////////

    or modify the code to:

    SLEEP &= ~0x04; // power up both osc, SLEEP.OSC_PD = 0
        while (!(SLEEP & 0x40)); ///wait until XOSC is stable, SLEEP.XOSC_STB = 1
        CLKCON = (CLKCON & ~0x47) | 0x40 | 0x01; // switch to HS RCOSC CLKCON.OSC = 1, set max CPU clock speed CLKCON.CLKSPD = 1
        while (!(CLKCON & 0x40)); // wait until system clock is actually changed CLKCON.OSC = 0
        SLEEP |= 0x04; // power down unused osc, HS XOSC, SLEEP.OSC_PD = 1 
        
    or changed the code to:
    SLEEP &= ~0x04; // power up both osc, SLEEP.OSC_PD = 0
        while (!(SLEEP & 0x40)); ///wait until XOSC is stable, SLEEP.XOSC_STB = 1
        CLKCON = (CLKCON & ~0x47) | 0x80 | 0x01; // switch to HS RCOSC CLKCON.OSC = 1, set max CPU clock speed CLKCON.CLKSPD = 1
        while ((CLKCON & 0x40)); // wait until system clock is actually changed CLKCON.OSC = 0
        SLEEP |= 0x04; // power down unused osc, HS XOSC, SLEEP.OSC_PD = 1 
        

    the board will not up, or up with the wrong PM2 sleep time  lasts.

          Please take a look, and give me some instruction. Thanks a lot!

  • Hi, Siri:

        As point to our boards, we just have a 26M crystal, and it's not connect to GND. (As the pdf  Table 29 mentioned: the 32H crystal is optional, and the Figure 10 also shows the 26M crystal doesn't need connect to GND (and we checked another company's .sch file, it's also not connect to GND) .)

       now the issue is still not resolved, please help us again. thanks!

  • Hi

    Here is a code example I just made showing how the CC1110 wakes up from PM2 every 1 s and toggles a led. The crystal is turned on every time it wakes up (as this is necessary if using the radio and turned off before entering PM2).

    // Initialization of source buffers and DMA descriptor for the DMA transfer
    unsigned char __xdata PM2_BUF[7] = {0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x04};
    unsigned char __xdata dmaDesc[8] = {0x00, 0x00, 0xDF, 0xBE, 0x00, 0x07, 0x20, 0x42};


    /*******************************************************************************
    * @fn  main
    *
    * @brief
    *      Main function.
    *
    * Parameters:
    *
    * @param  void
    *
    * @return void
    *
    *******************************************************************************/
    void main(void) {
     
      unsigned char temp;
     
      SLEEP &= ~0x04;                       // Power up both oscillators (HS XOSC and HS RCOSC)
      while (!(SLEEP & 0x40));             // Delay longer than max crystal start-up time (see errata)
      CLKCON = (CLKCON & ~0x47) | 0x01;     // Set high speed crystal oscillator as system clock running at 13 MHz
      while (CLKCON & 0x40);                // wait until system clock is actually changed CLKCON.OSC = 1
      SLEEP |= 0x04;                        // Power down unused osc
       
      //----------------------------------------------------------------------------
      // Init LEDs for debug purposes 
      P1DIR = 0x01;       // P1_0 (Grenn LED)  set as outputs
      G_LED = LED_OFF;
      //----------------------------------------------------------------------------
     
      //----------------------------------------------------------------------------
      // Update descriptor with correct source
      dmaDesc[0] = (unsigned int)& PM2_BUF >> 8;
      dmaDesc[1] = (unsigned int)& PM2_BUF;
       
      // Associate the descriptor with DMA channel 0 and arm the DMA channel
      DMA0CFGH = (unsigned int)&dmaDesc >> 8;
      DMA0CFGL = (unsigned int)&dmaDesc;
      DMAARM = 0x01;
      //----------------------------------------------------------------------------
       
     
      //----------------------------------------------------------------------------
      // Enable Sleep Timer interrupt   
      // 1. Clear interrupt flags
      STIF = 0;             // IRCON.STIF = 0
      WORIRQ &= ~0x01;      // WORIRQ.EVENT0_FLAG = 0
     
         
      // 2. Set individual interrupt enable bit in the peripherals SFR, if any
      WORIRQ |= 0x10;     // WORIRQ.EVENT0_MASK = 1
        
      // 3. Set the corresponding individual, interrupt enable bit in the
      // IEN0, IEN1, or IEN2 registers to 1
      STIE = 1;
     
      // 4 . Enable global interrupt by setting the IEN0.EA = 1
      INT_GLOBAL_ENABLE(INT_ON);
      
     
      while (TRUE) {
       
       
        SLEEP &= ~0x04;                             // Power up both oscillators (HS XOSC and HS RCOSC)
        while (!(SLEEP & 0x20));                   // Wait for the HSRCOSC to be stable
        CLKCON = (CLKCON & ~0x07) | 0x40 | 0x01;    // Set HSRCOSC as system clock running at 13 MHz
        while (!(CLKCON & 0x40));                      // wait until system clock is actually changed CLKCON.OSC = 1
        SLEEP |= 0x04;     

      
      
        
        // NOTE! At this point, make sure all interrupts that will not be used to
        // wake from PM are disabled as described in chapter 13.1.3 of the datasheet.
        // Align with positive 32 kHz clock edge as described in chapter 13.8.2
        // of the datasheet.
        char temp = WORTIME0;
        while( temp == WORTIME0);
        // Make sure XOSC is powered down when entering PM2/3 and that the flash
        // cache is disabled
        // NB! Replace 0x06 with 0x07 if power mode 3 is chosen instead
        MEMCTR |= 0x02;
        SLEEP = 0x06;
        // Enter power mode as described in chapter 13.1.3 in the datasheet.
        // Make sure DMA channel 0 is triggered just before setting PCON.IDLE
        asm("NOP");
        asm("NOP");
        asm("NOP");
        if(SLEEP & 0x03) {
          asm("MOV 0xD7,#0x01");  // DMAREQ = 0x01;
          asm("NOP");             // Needed to perfectly align the DMA transfer
          asm("ORL 0x87,#0x01");  // PCON |= 0x01;
          asm("NOP");
        }
        // Enable Flash Cache
        MEMCTR &= ~0x02;
      }
    }


    #pragma vector=ST_VECTOR
    __interrupt void st_IRQ(void)
    {   
        // Clear interrupt flags
        STIF = 0;        // IRCON.STIF = 0
        WORIRQ &= ~0x01; // WORIRQ.EVENT0_FLAG = 0
       
        // Note: It is necessary to clear the MODE bits before returning from all
        // ISRs associated with interrupts that can be used to wake the device from
        // PM{1 - 3}.
        SLEEP &= ~0x03; // SLEEP.MODE = 00 
        G_LED = ~G_LED;
       
        SLEEP &= ~0x04;                     // Power up both oscillators (HS XOSC and HS RCOSC)
        while (!(SLEEP & 0x40));            // Delay longer than max crystal start-up time (see errata)/////////////////////////////
        CLKCON = (CLKCON & ~0x47) | 0x01;   // Set high speed crystal oscillator as system clock running at 13 MHz
        while (CLKCON & 0x40);              // wait until system clock is actually changed CLKCON.OSC = 1
        SLEEP |= 0x04;     
     
    }

    BR

    Siri

  •  

    Hi

    I did not understand your comment about the 26 MHz crystal not being connected to ground. If the 32 kHz crystal is not needed, this can be removed and the pins can be left floating. For the 26 MHz crystal, this must be connected to ground through C201 and C211 as shown in figure 10.

    Siri

  • Hi, Siri:

         For our boards: the 32KHz crystal is removed, and the PIN 17,18 is not connect, left floating. And for the 26 MHz crystal, it has 4 pin,  we just connect 2 pin of the 26 MHz crystal with C201 and C211, C201 and C211 is connected to GND,  we left the other 2 pin of the 26 MHz crystal not connected, floating.

         And as for the code I test, if I flashed it into the evaluation board, which has a 32KHz crystal on it, and a led on it, It works fine, I can see the LED on/off in every second, and I also can receive RF data.  but when I flashed to our board, It still cannot wake on or wake on with the sleep time not right. (by  alternate changing the code :  while (!(SLEEP & 0x20));  ---  while (!(SLEEP & 0x40));  etc. )

          I know it must be something wrong on my code,  and got me a headache. 

         Thanks for your patience to help me!

         

        

  • Hi

    I am not sure how I can help you further as I am not able to recreate your problem. Since everything works on our EM but not on your HW it sounds like the problem is HW related (I just tested my code using the internal RCOSC instead of the 32 kHz crystal and it worked fine as well). I will have someone in the HW group take a look at this.

    To run on the internal RCOSC replace

    CLKCON = (CLKCON & ~0x47) | 0x01; with

    CLKCON = (CLKCON & ~0xC7) | 0x01; when turning on the crystal

    and

    CLKCON = (CLKCON & ~0x07) | 0x40 | 0x01; with

    CLKCON = (CLKCON & ~0x87) | 0x40 | 0x01; when turning on the HSRCOS

    Please take a look at http://www.ti.com/lit/swra241

    Here you will find info on how you can output some oscillator test signal to see that your oscillators are running correctly.

    BR

    Siri

  • Hi, Siri:

        Thanks for your help.

        I'll test it and check the settings, I think it needs some time. Wish I can resolve it soon.

        Thanks again!

  • If you want us to look at the hardware, please post schematic (pdf) and layout (as gerber). If you don't want to post them on a open forum, send me a friend request.

  • Hi, Ter:

          Thank you!

          I'v send you a friend request. 

         

  • Bit difficult to do a proper review without schematic and just a screen dump of the layout. The layout does not look optimal from a RF point of view but I could not see anything that should influence timing.

    Have you taken the 32k clock out on a pin and checked that the frequency is correct?

  • Hi,   Siri:

        Thanks you and TER,  and sorry to bother you again.

        I review the code again, and now is the result:

        the time was correct, but the current was not correct.

       You could see the following code:  If I don't add the SleepDMAInit() function, the board which can power up will cost about 0.5ma current, which is OK.  And after I add the  SleepDMAInit() function, flashed to the board which cannot power up, now it can power up, but the current cost about 4ma, and in the first several seconds it remains in about  22.2ma, it's not OK.

        For this result, I think it should be something wrong,  maybe cause the RF is on, and the ST is as timer, but I just add the SleepDMAInit() function list below. 

       Here is the code:

    void main ()
    {
        ...
        ///code as I post before 
        
        halInitSleepTimer();     
    
        while (TRUE)
        {
            int flag = ReadI2C(); ///read info from I2C
            
            if (flag)
            {
              radioInit( myAddress );
              TX_to_sendInfo(); ///went TX mode to send Info.
            }
            else
            {
              radioInit( myAddress );
              Rcv_data();       ///went RX mode to rcv info
            }
            
            setSleepTimerPeriod(100,MILLISECOND);    
            halResetSleepTimerAndEnterPM2();  
          
            if (received info){radioInit( myAddress );TX_to_SendAckInfo(); }  ///chk received info, and send ack .
          
             WDT_RESET(); ///feed dog
         }
    }
    
    
    void halInitSleepTimer(void)
    {
      INT_GLOBAL_ENABLE(INT_OFF);      
      SLEEP_TIMER_INIT();
      INT_SETFLAG(INUM_ST,INT_CLR);
    
      INT_ENABLE(INUM_ST,INT_ON);
      SLEEP_TIMER_ENABLE_EVENT0_INT(INT_ON);
      INT_GLOBAL_ENABLE(INT_ON);
    }
    
    void SleepDMAInit(void)
    {
        DMAARM |= 0x81;
        dmaDesc[0] = (unsigned int)& PM2_BUF >> 8;
        dmaDesc[1] = (unsigned int)& PM2_BUF;
        DMA0CFGH = (unsigned int)&dmaDesc >> 8;
        DMA0CFGL = (unsigned int)&dmaDesc;
        DMAIF = 0;  // also tried w/o this line, same effect
        DMAIRQ = 0; // also tried w/o this line, same effect
        DMAARM = 0x01;
        
        /////////////////////////////////////////////////////////////////////////////
        
        S1CON &= ~0x03; // clear RF CPU interrupt flag
        RFIF = 0;
        
        INT_ENABLE(INUM_ST, INT_ON);   // enable ST INT
        INT_GLOBAL_ENABLE(TRUE);   
    
        /////////////////////////////////////////////////
        // Errata approach: switch to XOSC
        // make sure XOSC is running at highest speed, i.e. 26MHz
        ////////////////////////////////////////////////
     
        SLEEP &= ~0x04;                     // Power up both oscillators (HS XOSC and HS RCOSC)
        while (!(SLEEP & 0x40));            // Delay longer than max crystal start-up time (see errata)/////////////////////////////
        CLKCON = (CLKCON & ~0xC7) | 0x01;   // Set high speed crystal oscillator as system clock running at 13 MHz
        while (CLKCON & 0x40);              // wait until system clock is actually changed CLKCON.OSC = 1 
        SLEEP |= 0x04; 
        
    }
    
    BYTE setSleepTimerPeriod(WORD time, TimeUnit_def uintV)
    {
      UINT32 temp = 0;
      BYTE wor_res = 0;
      float temp2;
      if( (uintV == MILLISECOND) && (time < 12) )return 3;
    
      SleepDMAInit(); ///NOTICE: add this code, the board which cannot power up before, can power now, and the time is correct now, but the current is high now.
      
      if (!(CLKCON & 0x80))  SET_32KHZ_CLOCK_SOURCE(RC);         
    
      if(CLKCON & 0x80)                                  
      {
        if( (uintV == HOUR) && (time > 17) )return 2;    
        temp2 = time * 104000 / 3;                       
      }
      else
      {
        if( (uintV == HOUR) && (time > 18) )return 2;     
        temp2 = time * 32768;
      }
    
      if(uintV == MILLISECOND)
      {
        temp2 /= 1000;
      }
      else
      {
        while(uintV > SECOND)                            
        {
          temp2 *= 60;
          uintV --;
        }
      }
      temp = (UINT32)temp2;
      while(temp > 0xffff)
      {
        temp >>= 5;
        wor_res ++;
      }
    
      WORCTL &= ~0X03;
      WOREVT1 = (BYTE)((WORD)temp>>8);
      WOREVT0 = (BYTE)((WORD)temp);
      WORCTL |= wor_res;
    
      return 0;                                           //on success, return 0
    }
    
    
    void  SET_POWER_MODE2(void)
    {
        char temp;
        
        SLEEP &= ~0x1B;
        SLEEP |= 2;
        //PCON |= 0x01;
    
        temp = WORTIME0;
        while(temp == WORTIME0);
    
        MEMCTR |= 0x02;
        SLEEP = 0x06;
    
        asm("NOP");
        asm("NOP");
        asm("NOP");
        if(SLEEP & 0x03)
        {
            asm("MOV 0xD7,#0x01");  // DMAREQ = 0x01;
            asm("NOP");  // Needed to perfectly align the DMA transfer.
            asm("ORL 0x87,#0x01"); // PCON |= 0x01;
            asm("NOP");
        }
        MEMCTR &= ~0x02;
    }
    
    void halResetSleepTimerAndEnterPM2(void)
    {
      BYTE temp;
      SLEEP_TIMER_RESET();
      WORIRQ &= ~0X01;
      temp = WORTIME0;
      while(temp == WORTIME0);
      temp = WORTIME0;
      while(temp == WORTIME0);                            ///
      INT_SETFLAG(INUM_ST,INT_CLR);
    
      SET_POWER_MODE2();
    
    }
    
    #pragma vector = ST_VECTOR
     __interrupt void ST_ISR(void)
    {
      INT_SETFLAG(INUM_ST,INT_CLR);
      WORIRQ &= ~0X01;
      SLEEP  &= ~0x03;
      
        /* ///add this code or not, doesnot affect
        SLEEP &= ~0x04;                     // Power up both oscillators (HS XOSC and HS RCOSC)
        while (!(SLEEP & 0x40));            // Delay longer than max crystal start-up time (see errata)/////////////////////////////
        CLKCON = (CLKCON & ~0x47) | 0x01;   // Set high speed crystal oscillator as system clock running at 13 MHz
        while (CLKCON & 0x40);              // wait until system clock is actually changed CLKCON.OSC = 1 
        SLEEP |= 0x04;  
        */
        
      return;
    }
    
    
    
    #pragma vector=RF_VECTOR
    __interrupt void spp_rf_IRQ(void)
    {
       BYTE enabledAndActiveInterrupt;
    
       INT_GLOBAL_ENABLE(INT_OFF);
       enabledAndActiveInterrupt = RFIF;
       RFIF = 0x00;                        // Clear all interrupt flags
       INT_SETFLAG(INUM_RF, INT_CLR);    // Clear MCU interrupt flag
       enabledAndActiveInterrupt &= RFIM;
    
       // Start of frame delimiter (SFD)
       if(enabledAndActiveInterrupt & IRQ_SFD)
       {
          if(sppRxStatus == RX_WAIT)
          {
             sppRxStatus = RX_IN_PROGRESS;
             RFIM &= ~IRQ_SFD;
          }
       }
    
       // Transmission of a packet is finished. Enabling reception of ACK if required.
       if(enabledAndActiveInterrupt & IRQ_DONE)
       {
          if(sppTxStatus == TX_IN_PROGRESS)
          {
             if(pAckData == NULL)
             {
                sppTxStatus = TX_SUCCESSFUL;
             }
             else
             {
                DMA_ARM_CHANNEL(dmaNumberRx);
             }
          }
    
          // Clearing the tx done interrupt enable
          RFIM &= ~IRQ_DONE;
    
       }
       INT_GLOBAL_ENABLE(INT_ON);
    }
    

  • Hi

    There is nothing in the SleepDMAInit that by itself cause a current consumption of 22 mA. This current consumption indicates that the radio is in active state (RX or TX).

    My only recommendation is that you test the different functions and corresponding current consumption one by one. Start with a code example where you only power up the closck and have the radio in IDLE and see this is OK. Then start by putting the radio in TX and confirm the TX current consumption. Do the same for RX.

    Then test PM2 by simply having a test code going up and down from PM2 and see that the current is OK then. After this, start putting the pieces together.

    It might be that things are not happening in the order you think they do and that initializing the DMA for use with the SLEEP timer interfers with the DMA used for RX/TX. Make sure that the radio is in IDLE state and when setting up the DMA for use with PM.

    BR

    Siri