Help > RITTLE FOR THE PIC32MZ MICROCONTROLLER > System Control > sleep


sleep (int_ms);

Put the system into sleep mode with minimum power consumption for a specified period of time, given in milliseconds. The typical accuracy of the sleep period is in around 32ms periods, so any values smaller than the granularity period, will cause an immediate wake up. Execution of all parallel processes is suspended.

NOTE: The current revision “B2” of the PIC32MZ EF microcontroller has an internal hardware problem with the sleep mode. That prevents it from achieving optimum sleep current, but instead, the minimum current remains as high as 9mA. Due to this and until Microchip manage to rectify the problem, the sleep() function will not be able to produce its desired result and it is recommended not to be used.

Value 0 for the parameter, will force the system into indefinite sleep with only remaining option to wake up from an external source.

Upon entering sleep mode, Rittle automatically configures pin 46 as input and enables its internal pull-up resistor. A falling edge on pin 46 will wake up the system and restore the last active frequency of the CPU clock, even if the specified time for sleep has not expired. Execution will continue with the instruction immediately following clock(). Pin 46 will remain configured as input but the pull-up resistor will be restored back to its initial disabled state. The user program will need to re-configure the port again if it is used for other purposes.