In some applications, the CPU only needs to work intermittently or process external events, and is usually in standby mode. The PIC16C5X microcontroller has a power-saving mode, the sleep (SLEEP) mode. In this mode, the oscillator driver stops working and the I/O port maintains the state before the SLEEP instruction is executed, 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" (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, the 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.
When SW2 is pressed, the red light is on. Readers can write processing programs according to actual needs, see Figure 2.
Before entering the sleep state, set the key scan output lines SCAN1 and SCAN2 to a low level. In this way, when entering the sleep state, 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 state and enter reset. During reset, SCAN1 and SCAN2 automatically change from output state to input state (high impedance state), the discharge circuit 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 the 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 a low level once every 20ms to sample the key value. To prevent the capacitor from discharging for too long, it will be pulled low to reset again. Each scan, that is, the time when SCAN1 or SCAN2 is low, 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 device re-enters the sleep state. R4-R8 is mainly used to prevent C from discharging and possibly causing damage to the chip. The working sequence is shown in Figure 3.
Previous article:PIC microcontroller memory bank 0 or 1 selection instructions (program)
Next article:Design of portable magnetic memory detector based on PIC microcontroller
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Allwinner heterogeneous multi-core AI intelligent vision V853 development board evaluation - The following error occurs when compiling eye-mppviplite-driver
- The maximum compensation is more than 200,000 yuan, and Toshiba’s Dalian factory is closed!
- Could you please help me analyze what the Darlington tube does in this circuit? Thank you.
- 550 Cases of Electrical Engineering Design and Calculation
- About BMS secondary protection chip
- [Perf-V Evaluation] Clock generation based on Perf-V development board
- Correctly understand the phase difference caused by capacitance and inductance
- 【SoC】Realize Ethernet interaction function
- Can anyone provide a download link for the AD package library (with 3D effects)? It's quite complete. Thank you.
- [ESP32-Korvo Review] (1) Development Board Circuit Connection