About PIC microcontroller SLEEP instruction

Publisher:书香墨意Latest update time:2020-01-30 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

I never really understood the sleep instruction before. Recently, when I was making a smart water meter product, I used an 8-bit microcontroller PIC16F690. When I saw the sleep instruction in the program, I thought the CPU would continue to work after execution, which led to some misunderstandings. I searched the Internet and found an article with detailed instructions on sleep. I have collected it for future reference!


Enter the sleep power saving mode after executing the SLEEP instruction. After entering the SLEEP mode, the main oscillation stops. If the watchdog is turned on during programming, the watchdog timer will be cleared and keep running. The I/O port, peripheral modules and internal RAM will remain in their original state, so if low power consumption is required after sleep, the IO port should be set to a high impedance input state before entering SLEEP, and unused modules should also be turned off. Some other peripheral modules are related to the main clock, such as USART in asynchronous mode, and will not work.


There are many conditions for waking up SLEEP, such as IO port level change, AD conversion completion, external reset, watchdog overflow, etc. For details, please refer to the data sheet. When the SLEEP instruction is executed, the PC+1 instruction is pre-fetched. When the device is awakened by an interrupt condition (this interrupt should be enabled), if GIE (global interrupt enable bit) is 0, the device will continue to execute the instruction following the SLEEP instruction. If GIE is 1, the device will execute the pre-fetched PC+1 instruction and jump to the interrupt entry of 0004H. Therefore, it is recommended that the instruction following SLEEP should be a NOP. External manual reset MCLR will wake up the device and RESET. The meaning of the flag bit indicating the status is detailed in the data sheet. The watchdog timer overflows under SLEEP to wake up the device, and then executes the instruction following SLEEP, and there is also a flag bit to indicate the status.


Reference address:About PIC microcontroller SLEEP instruction

Previous article:How to integrate the programming function of PIC microcontroller into ATE
Next article:PIC microcontroller timer (TMR0)

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号