Sleep & rtos

27 Mar 2015

Hello mbed community,

The sleep() method defined by "sleep_api.h" does not work when rtos is loaded. The cause is the system tick counter being enabled. Even if you disable the interrupt in the NVIC, it will still wake the controller, almost instantly.

This can be solved by disabling the system tick counter before and after the WFI instruction. For the LPC1768 this can be done with the following lines of code: Disable:

  • ((uint32_t*)0xE000E010) &= ( 0b1 << 0 ); Enable:
  • ((uint32_t*)0xE000E010) |= ( 0b1 << 0 );

Hope this helps.