📄 命令字加数据位程序备份.c
字号:
#include <reg52.h>
#include <absacc.h>
#define P3_2 P3^2
#define port XBYTE[0x3000];
unsigned char receive_sbuf;
unsigned char receive_7128;
unsigned char jingdu=0xff;
unsigned char weidu=0xff;
unsigned char nian=0xff;
unsigned char yue=0xff;
unsigned char ri=0xff;
unsigned char shi=0xff;
unsigned char fen=0xff;
unsigned char miao=0xff;
unsigned char OK=0xff;
unsigned char error=0;
void DS1302_init();
void main(void)
{
P1=0XF0; //点灯
//外中断设置
IT0=1; //外部中断0 下降沿中断
PX0=0; //外部中断优先级低
EX0=1; //开外部中断0
//串口设置
SCON=0x50; //模式1;允许接接收;标志位清0
PS=1; //串口中断高优先级
PCON=0X80;
TMOD=0x20; //方式2:自动装入
TL1=TH1=0xF3;
TR1=1; //波特率 4800@12Mhz)
ES = 1; //串口中断开
EA=1; //开总中断
SBUF=0xff;
while(1); //死循环等待中断
}
//串口中断程序
void int_s(void) interrupt 4
{
ES = 0; //关闭串行中断
if(TI==1)
{
//SBUF=0xff;
TI=0;
}
if(RI==1)
{
receive_sbuf=SBUF;
switch(receive_sbuf)
{
case 'E': jingdu=weidu=nian=yue=ri=shi=fen=miao=0x00; break;
case 'J': jingdu=0x00; break;
case 'W': weidu=0x00; break;
case 'N': nian=0x00; break;
case 'Y': yue=0x00; break;
case 'R': ri=0x00; break;
case 'S': shi=0x00; break;
case 'F': fen=0x00; break;
case 'M': miao=0x00; break;
case 'O': OK=0x00; break;
default : {
if(jingdu==0x00) jingdu=receive_sbuf;
if(weidu==0x00) weidu=receive_sbuf;
if(nian==0x00) nian=receive_sbuf;
if(yue==0x00) yue=receive_sbuf;
if(ri==0x00) ri=receive_sbuf;
if(shi==0x00) shi=receive_sbuf;
if(fen==0x00) fen=receive_sbuf;
if(miao==0x00) miao=receive_sbuf;
}
}
SBUF=receive_sbuf;
RI=0;
}
ES=1;
}
//外部中断程序
void hand(void) interrupt 0
{ //EX0=0;
ES=0; //关串口中断 (可能没必要)
P2=P2+0X01;
// port=0X44;
// EX0=1;
ES=1; //开串口中断
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -