📄 uuumain.c
字号:
////////////////////////////////////////////////////
#include "STC5410AD.H"
#include <ABSACC.H>
#include "uuu.h"
#include "variable.h"
#define pcastarth 0x1e
#define pcastartl 0x00
/****************************************************
* 功能:初始化
*****************************************************/
void InitializeSystem(void)
{
TMOD&=0x0f;
TMOD|=0x22;
PCON|=0x80; //SMOD=1;
TCON=0x05;
SCON=0x50; //初始化串口
P1M0=0x07;
P1M1=0x00;
P3M0=0x00;
P3M1=0x00;
ADC_CONTR=0xe0; //电流
TH0=0x06; //用于AD
TL0=0x06;
TH1=0x06;
TL1=0x06;
timer_time=20;
TR0=1;
TR1=1;
IE=0x82; //0x8f
IP=0x01;
alternation=0; //交替采样
power_drop_time=0; //电压跌落延时
P1=0xff;
uuu_fault=0;
}
/***********************************************************
* 功能:延时程序
***********************************************************/
/*void delay(uint useconds)
{
for(;useconds>0;useconds--);
}*/
/***************************************************************************
* 中断:外部中断0
****************************************************************************/
void int_int0(void) interrupt 0 using 1
{
}
/***************************************************************************
* 中断:定时器0[自动重装]
* 功能说明:每250uS中断一次,用于A/D采样
****************************************************************************/
void int_timer0(void) interrupt 1 using 1
{
ad_gather();
if(power_drop_time>0)power_drop_time--;
}
/***************************************************************************
* 中断:外部中断1,用于保码
****************************************************************************/
void int_int1(void) interrupt 2 using 1
{
}
/***************************************************************************
* 中断:定时器1 [自动重装]
* 功能说明:波特率发生器
****************************************************************************/
void int_timer1(void) interrupt 3 using 2
{
}
/*****************************************************************************
* 功能:串行中断,接收上位机数据
*****************************************************************************/
void seri_int (void) interrupt 4 using 2
{
uchar data rece_data;
rece_data=SBUF;
if(RI)
{ RI=0;
if(rece_data==0x3a)
{
send_num=0;
send_buf[0]=5;
SBUF=send_buf[0];
}
}
//---------------------------------------------
else if(TI) //发送
{
TI=0;
send_num++;
if(send_num<send_buf[0])SBUF=send_buf[send_num];
else send_num=0;
}
}
/***************************************************************************
* 中断:PCA中断 25ms中断一次
****************************************************************************/
void PCA_interrupt(void) interrupt 6 using 1
{
CCAP0L=pcastartl; //PCA0 定时常数
CCAP0H=pcastarth; //PCA0 定时常数
CCF0=0; //清PCA0 中断标志
CF=0;
pcatimecounter++;
if(pcatimecounter==40)
{
pcatimecounter=0;
}
}
/*******************************************************************
* 电压短时中断主函数
* 程序设计:JiangMaoZhou
* 最后修改时间:2007-1-19
*******************************************************************/
void main(void)
{
InitializeSystem(); //初始化
OUTDJ=1;
INDJ=1;
while(1)
{
WDT_CONTR=0x3c;
adc_solve();
power_check();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -