Here are comparison for two schemes: TIMAC-CC2430, TIMAC-CC2530.
- TIMAC-CC2430:
Entering PM2:
#define HAL_SLEEP_SET_POWER_MODE_REV_E(mode) st( SLEEP &= ~0x03; /* clear mode bits */ \
SLEEP |= mode; /* set mode bits */ \
asm("NOP"); \
asm("NOP"); \
asm("NOP"); \
if( SLEEP & 0x03 ) \
{ \
PCON |= 0x01; /* enable mode */ \
asm("NOP"); /* first instruction after sleep*/ \
}; )
HAL_ISR_FUNCTION() will clear SLEEP register:
#define CLEAR_SLEEP_MODE() st(SLEEP &= ~0x03;)
Risk: right after "if( SLEEP & 0x03 )", before"PCON |= 0x01; " the ISR happens and SLEEP register is cleared. The CC2430 datasheet shows that the device will enter power mode(in this case, power mode 0) set by SLEEP.MODE (note that MODE = 0x00 will stop CPU core, no peripherals, activity when this bit isenabled). And my experiment shows the device will reset(I think it is triggered by the watch dog timer)
- TIMAC-CC2530:
/* Prep CC2530 power mode */
HAL_SLEEP_PREP_POWER_MODE(halPwrMgtMode);
/* save interrupt enable registers and disable all interrupts */
HAL_SLEEP_IE_BACKUP_AND_DISABLE(ien0, ien1, ien2);
HAL_ENABLE_INTERRUPTS();
/* set CC2530 power mode, interrupt is disabled after this function
* Note that an ISR (that could wake up from power mode) which runs
* between the previous instruction enabling interrupts and before
* power mode is set would switch the halSleepPconValue so that
* power mode shall not be entered in such a case.
*/
HAL_SLEEP_SET_POWER_MODE();
void halSetSleepMode(void)
{
PCON = halSleepPconValue;
asm("NOP");
}
INT handler clear halSleepPconValue:
#define CLEAR_SLEEP_MODE() st( halSleepPconValue = 0; )
The code eliminate the risk in TIMAC-CC2430 by manipulating PCON register rather than SLEEP register
My question is why CC2430 can not apply the same code but leave risk as it is? Is there any chip level issue that can not be compromised? we have observed some issue regarding long sleep time, do we need to apply CC2530 scheme rather than TIMAC-CC2430 code?
please give me some advice whether we should change our CC2430 to the same code as in CC2530
thanks
Rui