Hi everybody,
                     This Ramakrishna and i am working on CC2430 SoC and
using tinyos-2.x-contrib. I wanted to test sleep modes( PM1,PM2,PM3) in
CC2430. i configured ST0,ST1 and ST2 registers for sleep time interval and
putting the mote into sleep mode using PCON register. It is going to sleep
mode, but not coming out of sleep mode and not giving any interrupt. Here
is my code. Any help is appreciated.


module SenderM
{
  provides interface Init;
  uses interface Boot;
  uses interface HalMcs51Led as Led1;
  uses interface HalMcs51Led as Led3;
  uses interface SimpleMac;
  uses interface StdControl as SimpleMacControl;
}

implementation{


  packet_t transmitPacket;

  task void sendPacketTask();
  task void delay();

  event void Boot.booted() {
    call SimpleMac.setChannel(11);
    call SimpleMacControl.start();
    call SimpleMac.setTransmitPower(100);

     IEN0 |= 0xA0;     //enable sleep timer
     STIF = 0x0;
     SLEEP &= 0xFC;
      post delay();

  }


  command error_t Init.init() {

    int i;
    transmitPacket.length = 7 + 2 + 3;
    transmitPacket.fcf = 0x0000;
    transmitPacket.data_seq_no = 0x00;
    transmitPacket.dest = 0xFFFF;
    transmitPacket.src = 0;
    transmitPacket.fcs.rssi = 0;
    transmitPacket.fcs.correlation = 0;
    for(i=0 ; i<transmitPacket.length-9; i++)
    transmitPacket.data[i] = i;

    return SUCCESS;
  }


  task void sendPacketTask()
  {

    call SimpleMac.sendPacket(&transmitPacket);

  }

  event void SimpleMac.sendPacketDone(packet_t *packet, error_t result)
  {
    uint32_t sleepTimer;
   if(result == SUCCESS)
   {

      SLEEP |= 0x01;
      asm("NOP");
      asm("NOP");
      asm("NOP");

      sleepTimer = 0xFF & ST0;
      sleepTimer += (((uint16_t)ST1)<<8);
      sleepTimer += (((uint32_t) ST2 & 0xFF)<<16);


      sleepTimer = (sleepTimer + (32768*5)) & 0x00FFFFFF;    //per sec
32768 ticks; then for 5 sec 32768*5

    //set sleep timer after 5 sec from the current time

      ST2 = (sleepTimer >> 16) & 0xFF;      //for 1.5 minute sleeping = 0x2F
      ST1 = (sleepTimer >> 8) & 0xFF;
      ST0 = sleepTimer & 0xFF;

      call Led1.toggle();
      PCON = 0x01;   //Enter into sleep mode PM1
      asm("NOP");

      SLEEP &= ~0x04;
      while ( ! (SLEEP & 0x40) );
      asm("NOP");
      CLKCON &= ~0x40;
   // Wait until system clock source has actually changed (CLKCON.OSC = 0)
      while ( CLKCON & 0x40 );
      SLEEP |= 0x04;
      call Led1.toggle();

      post delay();
   }


  }

task void delay()
{
   uint16_t i,j;
   for (i=0 ; i<0xFFFFU ; i++) {
    for (j=0 ; j<0xA ; j++) {
        }
    }
    post sendPacketTask();
}

  event packet_t * SimpleMac.receivedPacket(packet_t *packet)
  {
  }


  MCS51_INTERRUPT(SIG_ST)  //This Interrupt is not executing ...!
    {
        STIF = 0x0;
        call Led3.toggle();

    }

}


-- 
With Regards,
RamakrishnaReddy.S
CDAC,Bangalore.
_______________________________________________
Tinyos-help mailing list
Tinyos-help@millennium.berkeley.edu
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to