;This program is used to verify the watchdog and overflow time calculation formula of STC12C2052AD series microcontroller
;Watchdog and overflow time = (12 * Pre_scale *32768)/Oscillator Frequency
WDTCR EQU 0E1H ;Watchdog address
WDT_TIME_LED EQU P1.5 ;Use P1.5 to control the watchdog overflow time indicator light,
;The watchdog overflow time can be represented by the length of time the indicator light is on or off
WDT_FLAG_LED EQU P1.7 ;Use P1.7 to control the watchdog overflow reset indicator light, such as lighting, indicating a watchdog overflow reset
Last_WDT_Time_LED_Status EQU 00H ;Bit variable, stores the last status bit of the watchdog overflow time indicator light
;WDT reset time (Oscillator frequency = 18.432M Hz ):
;Pre_scale_Word EQU 00111100B ;Clear, start watchdog, prescaler number = 32 0.68S
Pre_scale_Word EQU 00111101B ;Clear, start watchdog, prescaler number = 64 1.36S
;Pre_scale_Word EQU 00111110B ; Clear to 0, start watchdog, prescaler = 128 2.72S
; Pre_scale_Word EQU 00111111B ; Clear to 0, start watchdog, prescaler = 256 5.44S
ORG 0000H
AJMP MAIN
ORG 0100H
MAIN:
MOV A, WDTCR ; Check if it is watchdog reset
ANL A, #10000000B
JNZ WDT_Reset ; WDTCR.7 = 1, watchdog reset, jump to watchdog reset program
; power-on reset, cold start, RAM unit content is random value
SETB Last_WDT_Time_LED_Status ; power-on reset,
; initialize the status bit of watchdog overflow time indicator = 1
CLR WDT_TIME_LED ; power-on reset, light up the watchdog overflow time indicator
MOV WDTCR, #Pre_scale_Word ;Start watchdogWAIT1
:
SJMP WAIT1 ;Execute this statement in a loop (stop), wait for watchdog overflow reset
; watchdog reset, hot start, RAM unit content remains unchanged, the value before reset
WDT_Reset: ; watchdog reset, hot start
CLR WDT_FLAG_LED ; light up the watchdog overflow reset indicator
JB Last_WDT_Time_LED_Status, Power_Off_WDT_TIME_LED
; set the WDT_TIME_LED light according to the last status bit of the watchdog overflow time indicator,
; if it was on last time, it will be off this time, if it was off last time, it will be on this time
CLR WDT_TIME_LED ; last time it was off, light up the watchdog overflow time indicator
CPL Last_WDT_Time_LED_Status ; invert the last status bit of the watchdog overflow time indicator
WAIT2:
SJMP WAIT2 ; Execute this statement in a loop (stop), wait for the watchdog overflow reset
Power_Off_WDT_TIME_LED:
SETB WDT_TIME_LED ; The watchdog overflow time indicator light was off this time if it was
on last time CPL Last_WDT_Time_LED_Status ; Invert the last status bit of the watchdog overflow time indicator light
WAIT3:
SJMP WAIT3 ; Execute this statement in a loop (stop), wait for the watchdog overflow reset
END
Previous article:Mobile phone battery charger program made by STC12C2052AD microcontroller
Next article:STC89C58RD+ internal EEPROM data FLASH-ISP-IAP
Recommended ReadingLatest update time:2024-11-16 01:23
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- 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
- Award-winning live broadcast | Beneng International launches millimeter-wave radar module based on Infineon technology, perfectly solving the pain points of the PIR market. Registration is open
- The principle of BLDC square wave sensorless control based on ADC sampling and integration
- [Allwinner heterogeneous multi-core AI intelligent vision V853 development board evaluation] ERROR: dl file rootfs.fex size too l...
- LTC3105 will not start
- Huawei is so poor that it has no money to buy keyboards and mice? Do you bring your own office supplies?
- TMS320C6000 Series DSP
- Review summary: BearPi-HM Micro foldable development board
- NeoPixel Infinity Cube
- [STM32F769Discovery development board trial] Discussion and application of DMA2D screen refresh efficiency
- Compilation of TI DM8148 multi-core DSP SDK