Key wake-up method for PIC16C5X microcontroller in sleep state

Publisher:SereneNatureLatest update time:2019-10-17 Source: eefocusKeywords:PIC16C5X Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

In some applications, the CPU only needs to work intermittently or process external events, and is usually in standby mode. The PIC16C5X microcontroller has an energy-saving mode, the sleep (SLEEP) mode. In this state, the oscillator driver stops working, and the I/O port maintains the state before executing the SLEEP instruction, thereby greatly reducing system power consumption. Since the PIC16C5X microcontroller has no interrupt function, there are only two ways to exit the sleep mode:

(1) Watchdog timer (WDT) overflow.


(2) Add a low level to the reset pin to reset the chip. This article adopts the second method. In the example given in Figure 1, PIC16C5X is usually in sleep mode. When any key is pressed, it wakes up from sleep mode and performs keyboard processing. For ease of explanation, in this example, when SW1 is pressed, it lights up, as shown in the figure below, as 

 

a green light; when SW2 is pressed, the red light lights up. Readers can write processing programs according to actual needs, see Figure 2. 

 

Before entering the sleep mode, set the key scan output lines SCAN1 and SCAN2 to a low level. In this way, when entering the sleep mode, when no key is pressed, the capacitor C is fully charged, so that the reset pin of the PIC16C5X microcontroller remains at a high level. Once a key is pressed, C discharges through resistor R2 or R3, causing the voltage on C to drop rapidly (about 1ms), thereby pulling the reset pin to a low level, forcing the PIC16C5X to exit the sleep mode and enter reset. When reset, SCAN1 and SCAN2 automatically change from output state to input state (high impedance state), the discharge loop of C is blocked, and VCC charges C to a high level through resistor R1.


It should be noted that the RC value should be selected appropriately so that the charge and discharge cycle is less than the reset time of PIC16C5X (about 18ms). It is also much less than the minimum time of key pressing (about 50--100ms). After the reset is completed, in the program, SCAN1 and SCAN2 are set to low level once every 20ms to sample the key value. In order to avoid the capacitor discharging time being too long, it will be pulled low to cause a reset again. Each scan, that is, the time when SCAN1 or SCAN2 is low level is about 10us. When the key processing program is completed, the program scans the keyboard cyclically until the key is released. Then the SCAN1 and SCAN2 outputs are set to low level and the computer goes back to sleep. R4-R8 is mainly used to prevent C from discharging and possibly causing damage to the chip. The working timing is shown in Figure 3. 

                          

Keywords:PIC16C5X Reference address:Key wake-up method for PIC16C5X microcontroller in sleep state

Previous article:Software and hardware implementation of serial communication between PIC16 series microcontroller and PC
Next article:PIC16F676 microcontroller internal EEPROM program

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号