STC12C2052AD MCU watchdog and its overflow time calculation formula

Publisher:钱币之歌Latest update time:2018-02-01 Source: eefocusKeywords:STC12C2052  MCU  watchdog Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

;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 


Keywords:STC12C2052  MCU  watchdog Reference address:STC12C2052AD MCU watchdog and its overflow time calculation formula

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

Study Notes - 51 MCU Serial Communication
1. Principle   The 8051 series microcontroller has a universal asynchronous receiver/transmitter (UART) for serial communication. When sending, data is led out from the TXD pin, and when receiving, data is input from the RXD pin. There are two buffers (Serial Buffer), one as a sending buffer and the other as a receivi
[Microcontroller]
Study Notes - 51 MCU Serial Communication
Fun single chip microcomputer - digital tube principle (I)
1. Internal structure of digital tube Digital tubes are also called LED digital tubes. Jingmei, Optoelectronics, and people from different industries have different names for digital tubes, but they are actually the same product. Digital tubes can be divided into seven-segment digital tubes and eight-segment digital
[Microcontroller]
Fun single chip microcomputer - digital tube principle (I)
Method of realizing PWM with 8051 single chip microcomputer
PWM stands for "Pulse Width Modulation". PWM actually outputs a series of rectangular waves on a pin of a microcontroller. Its period is generally fixed, and the time occupied by its high level and low level can be controlled and adjusted. The ratio of the time occupied by the high level and the low level is called th
[Microcontroller]
Method of realizing PWM with 8051 single chip microcomputer
Keyboard circuit example analysis: Pull-up resistor error causes 51 MCU to fail to operate normally
In circuit design, in order to maintain the resistor clamp at a high level, pull-up resistors are used to stabilize the resistor, so pull-up resistors begin to appear in circuit design in large quantities. This article uses the keyboard circuit as an example to analyze a situation where the 51 microcontroller circuit
[Microcontroller]
Keyboard circuit example analysis: Pull-up resistor error causes 51 MCU to fail to operate normally
51 single chip microcomputer realizes light source tracking
AD collects two voltages, compares them, controls the direction of motor rotation, and transmits the data to the host computer Xi'an University of Technology--School of Automation and Information Engineering Compiled by Zou Yiliang (2014.08.25) Email: 262276047@qq.com //******************************* //Xi'an
[Microcontroller]
51 MCU accumulates main cycle times to realize independent key press
1. Use proteus to draw a simple circuit diagram for subsequent simulation 2. Programming /******************************************************************************************************************** ---- @Project: Independent-KEY ---- @File: main.c ---- @Edit: ZHQ ----@Version: V1.0 ---- @CreationTime: 202
[Microcontroller]
51 MCU accumulates main cycle times to realize independent key press
EEPROM test program for STC15408AS microcontroller
I use a 4-bit 595-driven digital tube as data display; #include "STC15w408as.H" #include "intrins.h"   #define U8 unsigned char #define U16 unsigned int #include "EEPROM.H" //This file can be downloaded in the attachment sbit DS=P1^2; //Test key sbit SDA=P1^1; //595 drives the digital tube sbit CLK=P1^0; sbit ST=P3^7
[Microcontroller]
Experiment 7 Serial Communication (80C51 MCU Assembly Language Programming)
Host: reads the P1 port once every 1 second and sends the reading to the slave, and receives the slave's signal at the same time. If it is the same as the sent number, the P3.2 light will be on. If it is different or no response, the P3.3 light will be on. Slave: pushes the received data out of the P1 port and sends t
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号