Quantcast
Channel: Wireless Connectivity
Viewing all articles
Browse latest Browse all 116964

Forum Post: RE: CC2530 sleep timer

$
0
0

Woking Fine Sleep Timer Interrupt CC2530

Controller Wakes Up every 5 second and then Sleep

in sleep mode current is 1uA

in wake up mode Current is 15mA

#include <ioCC2530.h>

unsigned char volatile __xdata *ptr;
unsigned char firstbyte[8];
void Delay(){

unsigned int k;
for(k=0; k<65535; k++);
}


void SendChar1(unsigned char Get){

U1DBUF=Get;
while(!UTX1IF);
UTX1IF = 0;

}

void Serial_Int()
{



CLKCONCMD=0x00;

U0CSR |= 0x80; //UART mode selected for USART0.

U1CSR |= 0x80; //UART mode selected for USART0.

// U0UCR &= ~0x40; //H/w flow control disabled.

PERCFG &= ~0x01; //Alernative 1 selected for UART0 peripheral.

PERCFG |= 0x02; //Alernative 1 selected for UART0 peripheral.

P0SEL |= 0x0C; //P0.2 and P0.3 peripheral mode enabled.

P1SEL |= 0xF0; //P0.2 and P0.3 peripheral mode enabled.

// P1SEL &= ~0xF0;

U0GCR |= 0x08; U0BAUD = 0x3B; //Baud rate set to 9600 bps.


U1GCR |= 0x08; U1BAUD = 0x3B; //Baud rate set to 9600 bps.


}


static void SleepTimerInit(void);
unsigned char i,j;
int main (void)
{



P0DIR=0x03;
i=0;
j=0;

P0_0=0;
P0_1=0;
Serial_Int();

SleepTimerInit();


SLEEPCMD |= 0x06; // Setting power mode 2
PCON |= 0x01; // Enable power mode

while (1){

Delay();
P0_0=0;

Delay();
Delay();
Delay();

Delay();
Delay();
Delay();
P0_0=1;


PCON |= 0x01; // Enable power mode

}



}


static void SleepTimerInit(void)
{

unsigned long sleeptime = 0;

sleeptime |= ST0;
sleeptime |= (unsigned long)ST1 << 8;
sleeptime |= (unsigned long)ST2 << 16;


sleeptime += ((unsigned long)5 * (unsigned long)32753);

/* set sleep timer */
while((STLOAD & 0x01) == 0); // wait before ST0. STLOAD.LDRDY is 0 during the load
ST2 = (unsigned char)(sleeptime >> 16);
ST1 = (unsigned char)(sleeptime >> 8);
ST0 = (unsigned char) sleeptime;
STIE=1;


// IRCON |= 0x80;
IEN0 |= 0x20;
EA = 1; // Enable global interrupt

PCON=0X01;//go to sleep
}


#pragma vector=ST_VECTOR

__interrupt void sleeptimer_int()

{

unsigned long sleeptime = 0;
STIF = 0; //clear interrupt flag



sleeptime |= ST0;
sleeptime |= (unsigned long)ST1 << 8;
sleeptime |= (unsigned long)ST2 << 16;


sleeptime += ((unsigned long)10 * (unsigned long)32753);

/* set sleep timer */
while((STLOAD & 0x01) == 0); // wait before ST0. STLOAD.LDRDY is 0 during the load
ST2 = (unsigned char)(sleeptime >> 16);
ST1 = (unsigned char)(sleeptime >> 8);
ST0 = (unsigned char) sleeptime;

P0_0=0;

Delay();
P0_0=1;

Delay();
Delay();
Delay();

}


Viewing all articles
Browse latest Browse all 116964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>