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.

CC2530 wake-up

i hope you can help me out... i just can't wake-up my device after an IDLE mode or PM0.

Jonathan

/** Test Sleep main program **/
#include <iocc2530.h>

_Pragma ("vector=0x6B") __near_func __interrupt void P0_ISR(void);
_Pragma ("vector=0x6B") __near_func __interrupt void P0_ISR(void)

  P0IFG = 0xFE;     // Clear P0.0 interrupt flag.
  IRCON &= 0xDF;    // Clear Port 0 CPU interrupt flag.

}


void main(void)
{
 
  P1 = 0x00;
  P1DIR = 0x01;     // P1.0 as output
  P2INP = 0xE0;     // Port 0 and 1 as resistive pull-down.

  P0IE = 0xFF;      // P0 interrupts are enabled.
  EA = 1;           // Global interrupt is enabled.

  SLEEPCMD = (SLEEPCMD & 0xFC) | 0x00;
  PCON |= 0x01;

  asm("NOP");
  while(1)
  {  
   if (P0_1 != 0)
     P1_0 = 1;
   else
     P1_0 = 0;
  }
}

  • It does not look as if you have enabled the interrupt correctly. You must set both the bit corresponding to your pin in the P0IEN register to 1 and the P0IE bit of IEN1 to 1. You have only done the latter, and with a somewhat meaningless statement (P0IE = 0xFF, but P0IE is only 1 bit, so it can only be 0 or 1).

    Try replacing the P0IE = 0xFF instruction by:

    P0IEN |= 0x01; // Enable P0.1 interrupt
    P0IE = 1; // P0 interrupts are enabled.


  • Hey, I just tried your code..... but i think there's some other problems..... I don't know but my ISR just doesn't seem to work... I monitor it on the Osciloscope and i'm pretty sure I have a positive edge on my P0.1....  Could it be I have some problems with options for the project? (Like data pointers or banking?).. Uhh, if you simply place this in your IAR, would the LED1 go on for you......?

    Thanks in advance : )

    Jonathan

     

    /** Test Sleep main program **/
    #include <iocc2530.h>


    #pragma vector=P0INT_VECTOR
    __interrupt void Port0_ISR(void)
    {
      P1_0 = 1;         // Turn-on LED.
      P0IFG = 0xFD;     // Clear P0.1 interrupt flag.
      P0IF = 0;         // Clear Port 0 CPU interrupt flag.
    }

    void main(void)
    {
     
      P1 = 0x00;
      P1DIR = 0x01;  // P1.0 as output
      P2INP = 0xE0;  // Port 0 and 1 as resistive pull-down.

      P0IEN |= 0x01; // Enable P0.1 interrupt
      P0IE = 1;      // P0 interrupts are enabled.

      EA = 1;        // Global interrupt is enabled.

      asm("NOP");
     
      while (1)
        ;
    }

  • Whereas you posted this:

    P0IEN |= 0x01; // Enable P0.1 interrupt

    Shouldn't it be this:

    P0IEN |= 0x02; // Enable P0.1 interrupt

  • Yes, absolutely. Sorry about the error.

  • Yes!! thank you very much Dirty Harry and hec!!! It seems i have made a mistake on the ports and it's enable. Ohh this is quite a mistake i missed!! Thanks you very much!!