资源简介
无卡cdma校时模块,参考代码,用于cdma校时模块的开发;
代码片段和文件信息
#include“reg51.h“
#include“intrins.h“
#include“alldefine.h“
sbit LED = P0^5;
bit GetTimeFlag = 0;
bit CMOkFlag = 0; //为0:表示无通信,1:表示可接收数据
bit ReadTimeFlag = 0; //为1: 表示接收完数据
bit CDMARevData=0;
bit commChk;
bit SignFindFlag = 0;
bit SignCheckFlag = 0linkSignFlag = 0;
unsigned char GetTime[20] = {0};
unsigned char GetState[2] = {0};
unsigned char SignSave[2] = {‘0‘‘0‘};
unsigned char Year = 13Month = 3Day = 16Hour = 10Minute = 28Second = 4;
void T0Init(){
TMOD = 0x01; //10ms
TH0 = 0x4c;
TL0 = 0x00;
TR0 = 1;
ET0 = 1; //中断响应模式
EA = 1;
}
void SerialPort1Initial(){
SCON = 0x50;
BRT = 0xfa;
AUXR = 0x11; //9600 bps
PCON = 0x80;
//IP = 0x10; //优先级设为最高
ES = 1;
EA = 1;
}
void SerialPort2Initial(){
S2CON = 0x50;
BRT = 0xfa;
AUXR = 0x1c;
IE2 = 0x01;
EA = 1;
}
void SendDataPort2(unsigned char Sdata){
unsigned char Temp = 0;
//TR0 = 0;
//IE2 = 0x00;
S2CON &= 0xfd;
S2BUF = Sdata;
do{
Temp = S2CON;
Temp &= 0x02;
}while(Temp == 0);
S2CON &= 0xfd;
}
extern bit LcdDispFlag;
void T0Int() interrupt 1
{
static unsigned char T0Cnt = 0;
TH0 = 0x4c;
TL0 = 0x00;
GetTimeFlag = 1;
if(++T0Cnt > 19)
{
T0Cnt = 0;
LcdDispFlag = 1;
if(++ Second > 59)
{
Second = 0;
if(++Minute > 59)
{
Minute = 0;
if(++Hour > 23)
{
Hour = 0;
Day++;
if(Month == 2)
{
if(Year % 4 == 0)
{
if(Day > 29)
{
Day = 1;
if(++Month > 12)
{
Month = 1;
Year ++;
}
}
}
else
{
if(Day > 28)
{
Day = 1;
if(++Month > 12)
{
Month = 1;
Year ++;
}
}
}
}
else if(Month == 4 || Month == 6 || Month == 9 || Month == 11)
{
if(Day > 31)
{
Day = 1;
if(++Month > 12)
{
Month = 1;
Year ++;
}
}
}
else
{
if(Day > 30)
{
Day = 1;
if(++Month > 12)
{
Month = 1;
Year ++;
}
}
}
}
}
}
}
}
void SendDataPort1(unsigned char Sdata){
TI = 0;
SBUF = Sdata;
while(TI == 0);
TI = 0;
}
void RevPort2(void) interrupt 8
{ unsigned char k;
static unsigned char Rx0CntrPyte;
unsigned char RData;
k = S2CON;
k = k & 0x01;
if(k == 1){
S2CON = S2CON & 0XFE;
RData = S2BUF;
if(!CMOkFlag){ //接收OK
if(Rx0Cnt == 0 && (RData == ‘O‘ || RData == ‘o‘)){
Rx0Cnt ++;
}
else if(Rx0Cnt == 1 && (RData == ‘K‘ || RData == ‘k‘)){
Rx0Cnt = 0;
CMOkFlag = 1;
}
else{
Rx0Cnt = 0;
}
}
else{ //接收时间$HTIME: at$htime $HTIME: 2005/10/31 09:08:21 %STATE: 2
if(Rx0Cnt == 0 && RData == ‘$‘)
{
Rx0Cnt ++;
rPyte = 0;
}
else if(Rx0Cnt == 0 && RData == ‘+‘){
Rx0
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 275 2013-05-01 10:41 cdma_SysCode\alldefine.h
文件 9992 2013-06-01 19:42 cdma_SysCode\CDMA.c
文件 260 2013-06-01 19:42 cdma_SysCode\CDMA.h
文件 31822 2013-06-01 19:43 cdma_SysCode\CDMA.LST
文件 21732 2013-06-01 19:43 cdma_SysCode\CDMA.OBJ
文件 34917 2013-06-01 19:43 cdma_SysCode\cdma_sysCode
文件 41030 2013-06-01 19:43 cdma_SysCode\cdma_sysCode.M51
文件 1409 2013-06-01 19:43 cdma_SysCode\cdma_sysCode.Opt
文件 1679 2013-06-01 19:43 cdma_SysCode\cdma_sysCode.plg
文件 2078 2013-06-01 19:43 cdma_SysCode\cdma_sysCode.Uv2
文件 1255 2013-06-01 19:43 cdma_SysCode\cdma_sysCode_Opt.Bak
文件 2078 2013-06-01 19:43 cdma_SysCode\cdma_sysCode_Uv2.Bak
文件 3033 2011-08-28 10:04 cdma_SysCode\iic.C
文件 622 2011-08-27 10:40 cdma_SysCode\iic.h
文件 424 2011-09-04 19:05 cdma_SysCode\lcd.h
文件 2629 2013-06-01 19:43 cdma_SysCode\main.c
文件 7810 2013-06-01 19:43 cdma_SysCode\main.LST
文件 7851 2013-06-01 19:43 cdma_SysCode\main.OBJ
文件 14943 2011-09-04 19:09 cdma_SysCode\OCMJ2X16A.c
文件 25735 2013-06-01 19:43 cdma_SysCode\OCMJ2X16A.LST
文件 12857 2013-06-01 19:43 cdma_SysCode\OCMJ2X16A.OBJ
目录 0 2013-06-01 19:43 cdma_SysCode
----------- --------- ---------- ----- ----
224431 22
- 上一篇:个人软件外包合同模版
- 下一篇:无卡CDMA授时模块PCB参考图
评论
共有 条评论