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 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 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, 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:An example program for music playback based on PIC microcontroller
Next article:Battery monitoring circuit using PIC12C508 single chip microcomputer
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
- Common base amplifier circuit problems
- Analog input
- [Sipeed LicheeRV 86 Panel Review] 10-Video Playback Test
- [Silicon Labs BG22-EK4108A Bluetooth Development Review] VII. WeChat applet controls LED and receives button status 2
- May Day event is online! Let's do a "labor" transformation of old things together!
- Design a PCB diagram based on FPGA electronic piano
- 【GD32F310G-START】Evaluation Summary
- Please help with SMR24QTU NQAFM 2127S
- Software - Can I use the Breaking Master on my computer to install Allegro 16.6 and 17.4 at the same time?
- CC3120 Wireless Network Processor BoosterPack Plug-in Module