How can I put the XBee-PRO 900HP Programmable to Sleep Programmatically?

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.

It appears you can’t do this with the built-in Smart Project editor for some reason. I had to add this to custom.h:


/* power_management0 component */
#define ENABLE_POWER_MANAGEMENT
#define ENABLE_ON_SLEEP_XPIN_13
#define ENABLE_SLEEP_RQ
#define XBEE_ATCMD_PARAM_SM             1
#define XBEE_ATCMD_PARAM_SO             0
#define XBEE_ATCMD_PARAM_SP             (10000/10)
#define XBEE_ATCMD_PARAM_ST             2000
#define POWER_MANAGEMENT_KEEP_UPTIME    1
#define POWER_MANAGEMENT_ENABLE_LVD     0

1 Like

Hello jeffhaynes,

I didn’t understand what the problem is. The included PM support is not enough for what you want to do? As far as I understand, you want to put one device to sleep Asyncrhonously and yes, SDK doesn’t support that.

Maybe you could explain why the sdk doesn’t support that?