Marco Stevanoni

SMAC & low power : bugs?

Discussion created by Marco Stevanoni on Oct 23, 2006
Latest reply on Oct 27, 2006 by Kirit Basu
Hi all,
I tried to use SMAC with low power.
I started from an example appeared on SMAC4.1a release called SimpleNetwork. The example disappeared from release 4.1b and no example was published with low power features.
The problem is that all run ok until there is a crash of the fw and the Query remote doesn't respond anymore. Do you have any idea?

void main(void)
{

gsTxPacket.u8DataLength = 0;
gsTxPacket.pu8Data = &gau8TxDataBuffer[0];
gsRxPacket.u8DataLength = 0;
gsRxPacket.pu8Data = &gau8RxDataBuffer[0];
gsRxPacket.u8MaxDataLength = 10;
gsRxPacket.u8Status = 0;

/* Begin init */
MCUInit();
MCUPortInit(); //Set up unused ports for low power
MC13192Init();
MLMESetMC13192ClockRate(0); /* 16 MHz MC13192 CLKo */
UseExternalClock(); /* Now at 8 Mhz CPU bus */
LEDInit();
TPM1SC = 0x0F; /* Timer prescale by 128. (16uS timebase for 8MHz bus clock). */

/* Set up Real Time Interrupt for STOP3 very low power operation */
SRTISC = 0x17; //Enable RTI timer, internal clock, 1 sec wakeup
SPMSC1 = 0; //Disable all LVD functions
SPMSC2=SPMSC2&~0x03; /* Enable deep sleep mode stop3 (PDC & PPDC =0) */
SOPT_STOPE = 1; //Enable STOP mode(s)

/* Enable all IRQ sources. */
MC13192_IRQ_IE_BIT = 1;
EnableInterrupts;

MLMESetChannelRequest(Channel_Num); /* Choose your channel here */
MLMESetMC13192TmrPrescale(3); // Set 250 kHz timer rate
MLMEMC13192PAOutputAdjust(MAX_POWER);

/**************************************************************
* Main Loop
**************************************************************/

gu8AppStatus = LOOK_AROUND; //start by looking for request

for(;:smileywink: {

switch (gu8AppStatus)
{

case LOOK_AROUND:
UseMcuClock();
MLMEHibernateRequest(); //MC13192 now consuming 3 uA
DEAD_STOP3(); // Enter STOP3, MCU now consuming 1uA
MLMEWakeRequest();
UseExternalClock();
MLMERXEnableRequest(&gsRxPacket, 750); // 250 = 1mS timeout
LOW_POWER_WHILE(); //Stay until Interrupted for TO or data.
break;

case TX_IDnDATA:
gu8LinkQuality = MLMELinkQuality()/2;
gau8TxDataBuffer[0] = Net_ID; //Send our net #
gau8TxDataBuffer[1] = Remote_ID; //Send board ID #
gau8TxDataBuffer[2] = gu8LinkQuality; //Send link quality as data
gsTxPacket.u8DataLength = 3;
MCPSDataRequest(&gsTxPacket); // transmit data
WinkLED2x(); //Double-wink LED for good packet
gu8AppStatus = LOOK_AROUND; //return to await query mode
break;

case NO_DATA:
WinkLED1x(); //Show no packet for us
gu8AppStatus = LOOK_AROUND;
break;
}
}
}

void MCPSDataIndication(tRxPacket *gsRxPacket)
{
switch (gsRxPacket->u8Status)
{
case SUCCESS:
// Check for Host and ID match.
if ((gsRxPacket->pu8Data[0] == Net_ID) &&
(gsRxPacket->pu8Data[1] == Remote_ID))
{
gu8AppStatus = TX_IDnDATA; //enable response to host
}
else
{
gu8AppStatus = NO_DATA;
}
break;

case TIMEOUT:
gu8AppStatus = NO_DATA;
break;

case OVERFLOW:
break;
}
}

Outcomes