<
hotpower
/*---------------------------------------------------------
STC单片机IO管脚毁坏动态自检程序
HotPower@126.com 2005.6.6
----------------------------------------------------------*/
#i nclude
#i nclude
#i nclude
#i nclude
#i nclude
#pragma NOAREGS
//STC ISP_V2.0 PCB的晶振为18.432MHz
#define WdtTime_71_1mS 0x30 //71.1mS
#define WdtTime_141_2mS 0x31 //141.2mS
#define WdtTime_284_4mS 0x32 //284.4mS
#define WdtTime_568_8mS 0x33 //568.8mS
#define WdtTime_1_1377S 0x34 //1.1377S
#define WdtTime_2_755S 0x35 //2.755S
#define T2_5mS -1536*5//5ms 18.432MHz
/*------------------------------------------------
AT89S5X
--------------------------------------------------*/
sfr AUXR = 0x8e;
sfr WDTRST = 0xa6;
sfr16 TIMEER2 = 0xcc;
sfr16 RCAP = 0xca;
/*------------------------------------------------
STC89C5XRC
--------------------------------------------------*/
sfr WDT_CONTR = 0x0e1;
//全局变量定义
typedef struct Systemstruct{//系统数据结构
unsigned char TimeCount;
unsigned int RamTest;
unsigned char SioTxCount;
unsigned char SioTxSum;
unsigned char SioRxCount;
unsigned char SioTxBuff[32];
// unsigned char SioRxBuff[32];
}SystemData;
data SystemData SystemBuffers;//申请系统数据结构
void MainInit(void);//系统初始化
void SystemInit(void);//系统初始化
void SystemSetup(void);//系统设置
void SystemIoInit(void);//系统接口初始化
void TimeInit(void);//定时器定时参数设置
void UserSetup(void);//用户运行环境设置
void ClrWdt(void);//喂狗
void IoPinTest(void);
unsigned char Port0Test(void);
unsigned char Port1Test(void);
unsigned char Port2Test(void);
unsigned char Port3Test(void);
void main(void)
{
MainInit();//系统初始化
while (1) {//主循环
IE |= 0xb2;//保证中断可靠EA,ET2,ES,ET0
TCON |= 0x55;//保证定时器开
PCON |= SMOD_ GF0_ IDL_;//进入空闲状态并喂软件狗
_nop_();
_nop_();
}
}
void MainInit(void) using 0//系统初始化
{
ClrWdt();//清除看门狗计数器
SystemIoInit();//系统接口初始化
SystemInit();//系统上电初始化
SystemSetup();//系统运行环境设置
UserSetup();//用户运行环境设置
}
void SystemInit(void) using 0//系统初始化
{
if (SystemBuffers.RamTest != 0x55aa) {//内存初始化
SystemBuffers.RamTest = 0x55aa;
}
else {
}
}
void SystemSetup(void) using 0//系统设置
{
TimeInit();
}
void SystemIoInit(void) using 0
{
IE = 0x00;//关闭中断
P2 = 0xff;//P2口初始化
P0 = 0xff;//P0口初始化
P1 = 0xff;//P1口初始化
P3 = 0xff;//P3口初始化
}
void TimeInit() using 0
{
// TCON = 0x55;//启动定时器
/*----------------------------------
本新闻共3页,当前在第1页 [1] [2] [3]
|
|