AT89S52单片机看门狗不正常
时间:10-02
整理:3721RD
点击:
#include "reg52.h"
#include "intrins.h"
#include "macro.h"
#include "Delay.h" //延时
sfr WDTRST=0xA6; //声明寄存器
void main()
{
WDTRST=0x1E; //激活看门狗,先送1E,后送E1
WDTRST=0xE1;
Serial_Init();
WDTRST=0x1E; //激活看门狗,先送1E,后送E1
WDTRST=0xE1;
while(1)
{
WDTRST=0x1E; //激活看门狗,先送1E,后送E1
WDTRST=0xE1;
Delay1ms(); //1ms
Delay1ms(); //2ms
Delay1ms(); //3ms
Delay1ms(); //4ms
Delay1ms(); //5ms
Delay1ms(); //6ms
Delay1ms(); //7ms
Delay1ms(); //8ms
//Delay1ms(); //9
//Delay1ms(); //10
WDTRST=0x1E; //激活看门狗,先送1E,后送E1
WDTRST=0xE1;
Delay1ms(); //1
Delay1ms(); //2
Delay1ms(); //3
Delay1ms(); //4
Delay1ms(); //5
Delay1ms(); //6
Delay1ms(); //7
Delay1ms(); //8
Delay1ms(); //9,执行完这句,看门狗溢出,程序复位到main第一句开始执行
//Delay1ms(); //10
Send_Byte_Serial(0x55); //串口发数
//Delay500ms();
}
}
//程序的目的是验证看门狗是否正常工作,正常的话串口输出之前看门狗已经复位系统,所以串口不会发送数据,仿真没有问题,但是下载到电路板上发现串口会循环发数据.
#include "intrins.h"
#include "macro.h"
#include "Delay.h" //延时
sfr WDTRST=0xA6; //声明寄存器
void main()
{
WDTRST=0x1E; //激活看门狗,先送1E,后送E1
WDTRST=0xE1;
Serial_Init();
WDTRST=0x1E; //激活看门狗,先送1E,后送E1
WDTRST=0xE1;
while(1)
{
WDTRST=0x1E; //激活看门狗,先送1E,后送E1
WDTRST=0xE1;
Delay1ms(); //1ms
Delay1ms(); //2ms
Delay1ms(); //3ms
Delay1ms(); //4ms
Delay1ms(); //5ms
Delay1ms(); //6ms
Delay1ms(); //7ms
Delay1ms(); //8ms
//Delay1ms(); //9
//Delay1ms(); //10
WDTRST=0x1E; //激活看门狗,先送1E,后送E1
WDTRST=0xE1;
Delay1ms(); //1
Delay1ms(); //2
Delay1ms(); //3
Delay1ms(); //4
Delay1ms(); //5
Delay1ms(); //6
Delay1ms(); //7
Delay1ms(); //8
Delay1ms(); //9,执行完这句,看门狗溢出,程序复位到main第一句开始执行
//Delay1ms(); //10
Send_Byte_Serial(0x55); //串口发数
//Delay500ms();
}
}
//程序的目的是验证看门狗是否正常工作,正常的话串口输出之前看门狗已经复位系统,所以串口不会发送数据,仿真没有问题,但是下载到电路板上发现串口会循环发数据.