I’m struggling with the XBee PRO 900HP Programmable 32K. I have two devices and I would like to put one into sleep like this:
pm_set_radio_mode(PM_MODE_STOP);
/* Radio doesn't sleep immediately even when requested.
* Don't sleep the CPU until radio is already slept to prevent a false
* awake of the CPU caused by the high to low edge of the On/Sleep radio pin.
*/
if (pm_get_radio_mode() == PM_MODE_STOP)
{
printf("Stage: going to sleep
");
delay_ticks(2); /* This is for avoiding writing garbage on the UART */
pm_set_cpu_mode(PM_MODE_STOP, WAIT_INFINITE); /* Start sleeping */
/* When CPU wakes-up, it continues executing from here */
sendRequest = TRUE;
pm_set_radio_mode(PM_MODE_RUN);
/* We need to wait for the radio to be ON; it will take about 14mS. */
while (pm_get_radio_mode() != PM_MODE_RUN)
;
printf(" Device status: awake
");
}
However, no matter what Sleep Mode I choose, it doesn’t seem to respect the commands. I do not want to use the cyclic sleep stuff where it can only send every so often (and I was told this is possible). I would like the button IRQ to bring the CPU out of sleep (which would then in turn awake the radio).
EDIT: It seems like part of the problem may be that CodeWarrior studio will only support SYNC and ASYNC sleep options in the SM dropdown but I’m not sure how to fix it/override it. If I don’t add the Power Management module then the project doesn’t include the PM libs.