``资料是论坛的,我用的是12M的晶振,但是实际运行中,遥控器无法使用,即使使用也无法实现遥控功能,仅仅是要显示汉字变时间和日期,,
/*********************************旋转LED字体 时钟程序**************************************************
由于我们水平有限 提供的程序都是初级水平的 望大家多多指教!
需要改进的地方还很多,我们在后续中也会不断升级!
功能简介:
单片机 STC89C52 LQFP封装 22.1184M晶振
字体和数字钟程序!
红外遥控调时间和切换模式!
板上自带DS1302时钟芯片!有掉电保护!
自适应旋转速度 在电机有点转速不均匀的问题得到很好的解决 使得稳定显示
******************************************************************************************************/
//
#include "reg51.h"
#include "intrins.h"
#define uchar unsigned char
#define uint unsigned int //宏定义
//手动添加定时器2寄存器定义
sfr T2CON = 0xC8;
sfr TL2 = 0xCC;
sfr TH2 = 0xCD;
sfr RCAP2L = 0xCA;
sfr RCAP2H = 0xCB;
***it TF2 = T2CON^7;
***it EXF2 = T2CON^6;
***it RCLK = T2CON^5;
***it TCLK = T2CON^4;
***it EXEN2 = T2CON^3;
***it TR2 = T2CON^2;
***it C_T2 = T2CON^1;
***it CP_RL2= T2CON^0;
***it ET2 =0xAD;
***it KEY=P3^2;
***it led1=P1^1;
***it ACC0=ACC^0; //1bit数据存储位
***it ACC7=ACC^7;
***it T_CLK=P3^5; //DS1302引脚连接
***it T_IO =P3^6;
***it T_RST=P3^7;
uchar irtime;//红外用全局变量
uint TimeCount=0;
uint DelayN=80, //延时临时计数
DelayTime=80; //每次延时的周期个数
bit irokk,flag;
uchar IRcord[2];
uchar irdata[17];
uint j,k;
uchar miao,Cent,Hour,Month,Day,Week,count,id,mode;
uchar starts_time[7]={0x00,0x10,0x22,0x22,0x09,0x03,0x10}; //初始化后设置
void Set_id(uchar sel,uchar sel_1);
void display(void);
unsigned char code zimo[] = {
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,/*" ",0*/
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF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E,0xFB,0xDE,0xFB,0xAE,0xFC,0x71,0xFF,0xFF,/*"8",8*/
0xFF,0xFF,0xFE,0x3F,0xFD,0xDC,0xFB,0xEE,0xFB,0xEE,0xFD,0xDD,0xFE,0x03,0xFF,0xFF,/*"9",9*/
0xFF,0xFF,0xFF,0xDF,0xFF,0xDF,0xFF,0xDF,0xFF,0xDF,0xFF,0xDF,0xFF,0xDF,0xFF,0xFF,/*"-",10*/
};
/******************************************************************************************/
/*********延时子程序**********/
void DelayUs(uchar n)
{
for(;n>0;n--){
DelayN=DelayTime;
while (DelayN);
}
}
/**************************************************/
void tim1_isr (void) interrupt 3 using 3//定时器1中断服务函数
{
irtime++;
}
//外部中断解码程序
void ex1_isr (void) interrupt 2 using 2//外部中断1服务函数
{
static unsigned char i,w,z;
static bit startflag;
if(startflag)
{
if(irtime<126&&irtime>=69)//引导码 TC9012的头码 63 33
{ i=0;
w=1;
z=0;
irdata[i]=irtime;
irtime=0;
}
z++;
if(z>=18)
{
irdata[w]=irtime;
irtime=0;
w++;
if(w==17)
{
irokk=1;
w=0;
}
}
else
irtime=0;
}
else
{irtime=0;startflag=1;}
}
/************************************************/
void Ircordpro(void)//红外码值处理函数
{
unsigned char i, j, k;
unsigned char cord,value;
k=1;
for(i=0;i<2;i++)//处理2个字节
{
for(j=1;j<=8;j++) //处理1个字节8位
{
cord=irdata[k];
if(cord>10)//大于某值为1 7
{
value=value|0x80;
}
else
{
value=value;
}
if(j<8)
{
value=value>>1;
}
k++;
}
IRcord[i]=value;
value=0;
}
}
/****************************************************************/
//定时器0
void t2(void) interrupt 5 //定时器2中断子程序
{
TF2=0;
count++;
if(count>10)
{
count=0;
flag=~flag;
}
}
/**************************************************************/
void timer0() interrupt 1 using 1 //定时器0中断子程序
{
TimeCount++;
if (DelayN!=0)
DelayN--;
}
/*******************DS1302读写程序**********************************
/********************************************************************
函 数 名:RTInputByte()
功 能:实时时钟写入一字节
说 明:往DS1302写入1Byte数据 (内部函数)
入口参数:d 写入的数据
返 回 值:无
***********************************************************************/
void RTInputByte(uchar d)
{
uchar h;
ACC = d;
for(h=8; h>0; h--)
{
T_IO = ACC0; /*相当于汇编中的 RRC */
T_CLK = 1;
T_CLK = 0;
ACC = ACC >> 1;
}
}
/********************************************************************
函 数 名:RTOutputByte()
功 能:实时时钟读取一字节
说 明:从DS1302读取1Byte数据 (内部函数)
入口参数:无
返 回 值:ACC
设 计:zhaojunjie 日 期:2002-03-19
修 改: 日 期:
***********************************************************************/
uchar RTOutputByte(void)
{
uchar h;
for(h=8; h>0; h--)
{
ACC = ACC >>1; /*相当于汇编中的 RRC */
ACC7 = T_IO;
T_CLK = 1;
T_CLK = 0;
}
return(ACC);
}
/********************************************************************
函 数 名:W1302()
功 能:往DS1302写入数据
说 明:先写地址,后写命令/数据 (内部函数)
调 用:RTInputByte() , RTOutputByte()
入口参数:ucAddr: DS1302地址, ucData: 要写的数据
返 回 值:无
***********************************************************************/
void W1302(uchar ucAddr, uchar ucDa)
{
T_RST = 0;
T_CLK = 0;
T_RST = 1;
RTInputByte(ucAddr); /* 地址,命令 */
RTInputByte(ucDa); /* 写1Byte数据*/
T_CLK = 1;
T_RST = 0;
}
/********************************************************************
函 数 名:R1302()
功 能:读取DS1302某地址的数据
说 明:先写地址,后读命令/数据 (内部函数)
调 用:RTInputByte() , RTOutputByte()
入口参数:ucAddr: DS1302地址
返 回 值:ucData :读取的数据
***********************************************************************/
uchar R1302(uchar ucAddr)
{
uchar ucData;
T_RST = 0;
T_CLK = 0;
T_RST = 1;
RTInputByte(ucAddr); /* 地址,命令 */
ucData = RTOutputByte(); /* 读1Byte数据 */
T_CLK = 1;
T_RST = 0;
return(ucData);
}
/********************************************************************
函 数 名:Set1302()
功 能:设置初始时间
说 明:先写地址,后读命令/数据(寄存器多字节方式)
调 用:W1302()
入口参数:pClock: 设置时钟数据地址 格式为: 秒 分 时 日 月 星期 年
7Byte (BCD码)1B 1B 1B 1B 1B 1B 1B
返 回 值:无
***********************************************************************/
void Set1302(uchar *pClock)
{
uchar h;
uchar ucAddr = 0x80;
W1302(0x8e,0x00); /* 控制命令,WP=0,写操作?*/
for(h =7; h>0; h--)
{
W1302(ucAddr,*pClock); /* 秒 分 时 日 月 星期 年 */
pClock++;
ucAddr +=2;
}
W1302(0xc0,0x01);
W1302(0XC2,0X03); //初始自动转换显示时间为3秒。
W1302(0x8e,0x80); /* 控制命令,WP=1,写保护?*/
}
/******************读取DS1302中的时间****************/
void du1302()
{
miao=R1302(0x81); //对取 秒 分 时 日 月 星期 年
Cent=R1302(0x83);
Hour=R1302(0x85);
Day=R1302(0x87);
Month=R1302(0x89);
Week=R1302(0x8b);
}
/*****************************************************/
//根据选择调整相应项目
void Set_id(uchar sel,uchar sel_1)
{
signed char time;
uchar max,min,address;
if(sel==1) {address=0x84; max=23;min=0;} //小时
if(sel==2) {address=0x82; max=59;min=0;} //分钟
if(sel==3) {address=0x88; max=12;min=1;} //月
if(sel==4) {address=0x86; max=31;min=1;} //日
if(sel==5) {address=0x8a; max=7;min=1;} //星期
time=R1302(address+1)/16*10+R1302(address+1)%16;
if (sel_1==0) time++; else time--;
if(time>max) time=min;
if(time<min) time=max;
W1302(0x8e,0x00);
W1302(address,time/10*16+time%10);
W1302(0x8e,0x80);
}
/*********************************************************/
//加减键与显示
void id_case1_key(void)
{
if (IRcord[0]==0x0A)
{
IRcord[0]=0x00;
Set_id(id,0);
}
if (IRcord[0]==0x09)
{
IRcord[0]=0x00;
Set_id(id,1);
}
}
/*****************************************************/
//按键扫描 显示时间及闪烁位选择
void Scan_Key(void)
{
if(IRcord[0]==0x0E)
{
IRcord[0]=0x00;
id++;
if(id>5)
id=0;
}
id_case1_key();
}
/***********************************************************/
void display(void)
{
uchar i;
/******************显示时分秒数据**************************/
if((flag==1)&&(id==1)) //实现调时 的闪烁位 (以下同)
{
for(i=0;i<8;i++) //这里用16个LED实现时间显示(以下同)
{
P2=0xFF; //时的十位不显示(亮灭的结合就实现了闪烁)
P0=0XFF;
DelayUs(1);
}
P0=0XFF;
P2=0XFF;
for(i=0;i<8;i++)
{
P0=0XFF;
P2=0XFF; //时的个位不显示
DelayUs(1);
}
P0=0XFF;
P2=0XFF;
}
else
{
for(i=0;i<8;i++) //这里用8个LED实现时间显示
{
P0=tab[Hour/16][i*2]; //时的十位
P2=tab[Hour/16][i*2+1];
DelayUs(1);
}
P0=0XFF;
P2=0XFF;
for(i=0;i<8;i++)
{
P0=tab[Hour%16][i*2]; //时的个位
P2=tab[Hour%16][i*2+1];
DelayUs(1);
}
P0=0XFF;
P2=0XFF;
}
for(i=0;i<8;i++)
{
P0=tab[10][i*2]; //显示两点
P2=tab[10][i*2+1];
DelayUs(1);
}
P0=0XFF;
P2=0XFF;
/******************************************************/
if((flag==1)&&(id==2))
{
for(i=0;i<8;i++)
{
P0=0XFF;
P2=0XFF; //分的十位不显示
DelayUs(1);
}
P0=0XFF;
P2=0XFF;
for(i=0;i<8;i++)
{
P0=0XFF;
P2=0XFF; //分的个位不显示
DelayUs(1);
}
P0=0XFF;
P2=0XFF;
}
else
{
for(i=0;i<8;i++)
{
P0=tab[Cent/16][i*2]; //分的十位
P2=tab[Cent/16][i*2+1];
DelayUs(1);
}
P2=0XFF;
P0=0XFF;
for(i=0;i<8;i++)
{
P0=tab[Cent%16][i*2]; //分的个位
P2=tab[Cent%16][i*2+1];
DelayUs(1);
}
P0=0XFF;
P2=0XFF;
}
for(i=0;i<8;i++) //显示两点
{
P0=tab[10][i*2];
P2=tab[10][i*2+1];
DelayUs(1);
}
P0=0XFF;
P2=0XFF;
/***********************************************/
for(i=0;i<8;i++)
{
P0=tab[miao/16][i*2]; //秒的十位
P2=tab[miao/16][i*2+1];
DelayUs(1);
}
P0=0XFF;
P2=0XFF;
for(i=0;i<8;i++)
{
P0=tab[miao%16][i*2]; //秒的个位
P2=tab[miao%16][i*2+1];
DelayUs(1);
}
P0=0XFF;
P2=0XFF;
/*********************显示月日数据***************************/
DelayUs(25); //这里延时的作用是 把日期与时间拉开距离
/******************显示星期数据******************************/
if((flag==1)&&(id==5))
{
for(i=8;i>0;i--)
{
P0=0xFF; //星期值不显示
P2=0xFF;
DelayUs(1);
}
P0=0xFF; //星期值不显示
P2=0xFF;
}
else
{
for(i=8;i>0;i--)
{
P2=tab1[Week][i*2]; //星期值
P0=tab1[Week][i*2+1];
DelayUs(1);
}
}
P0=0xFF;
P2=0XFF;
/****************************************************/
for(i=7;i>0;i--)
{
P2=tab1[10][i*2]; //-字符
P0=tab1[10][i*2+1];
DelayUs(1);
}
P0=0XFF;
P2=0XFF;
/****************************************************/
if((flag==1)&&(id==4))
{
for(i=8;i>0;i--)
{
P0=0XFF;
P2=0XFF; //日期个位不显示
DelayUs(1);
}
P0=0XFF;
P2=0XFF;
for(i=8;i>0;i--)
{
P0=0XFF; //日期十位不显示
P2=0XFF;
DelayUs(1);
}
P0=0XFF;
P2=0XFF;
}
else
{
for(i=8;i>0;i--)
{
P2=tab1[Day%16][i*2]; //日期个位
P0=tab1[Day%16][i*2+1];
DelayUs(1);
}
P0=0XFF;
P2=0XFF;
for(i=8;i>0;i--)
{
P2=tab1[Day/16][i*2]; //日期十位
P0=tab1[Day/16][i*2+1];
DelayUs(1);
}
}
P0=0XFF;
P2=0XFF;
/******************************************/
for(i=7;i>0;i--)
{
P2=tab1[10][i*2]; //-字符
P0=tab1[10][i*2+1];
DelayUs(1);
}
P0=0XFF;
P2=0XFF;
if((flag==1)&&(id==3))
{
for(i=8;i>0;i--)
{
P0=0XFF;
P2=0XFF; //月的个位不显示
DelayUs(1);
}
P0=0XFF;
P2=0XFF;
for(i=8;i>0;i--)
{
P0=0XFF;
P2=0XFF; //月的十位不显示
DelayUs(1);
}
P0=0XFF;
P2=0XFF;
}
else
{
for(i=8;i>0;i--)
{
P2=tab1[Month%16][i*2]; //月的个位
P0=tab1[Month%16][i*2+1];
DelayUs(1);
}
P0=0XFF;
P2=0XFF;
}
for(i=8;i>0;i--)
{
P2=tab1[Month/16][i*2]; //月的十位
P0=tab1[Month/16][i*2+1];
DelayUs(1);
}
P0=0XFF;
P2=0XFF;
}
/***********************************************************/
/*****主函数*****/
void main(void)
{
TMOD=0x22;//定时器0工作方式2 定时器1工作方式2,TH0是重装值,TL0是初值
TH0=0x80; //设定定时器0初值
TL0=0x80;
TR0=1;
ET0=1;
TH1=0x00;//reload value
TL1=0x00;//initial value
ET1=1;//开中断
TR1=1;
RCAP2H = 0x3C; //定时器2 定时50MS
RCAP2L = 0x0B0;
ET2 = 1;
TR2=1;
//外部中断
IT1 = 1; // Configure interrupt 0 for falling edge on /INT0 (P3.3)
EX1 = 1; // Enable EX1 Interrupt
EA = 1; //开总中断
led1=0;
mode=2;
while(1) //无限循环
{
if(irokk==1)
{
Ircordpro();
irokk=0;
}
if(IRcord[0]==0x1A)//红外遥控的按键值 不同的遥控器不同的按键值不同 根据实际改 以下按键功能相同
{
Set1302(starts_time); //初始化
W1302(0x8e,0x00); //控制命令,WP=0,写操作
W1302(0x90,0xa5); //打开充电二级管 一个二级管串联一个2K电阻
}
if(IRcord[0]==0x10)
{
IRcord[0]=0x00;
mode=1;
}
if(IRcord[0]==0x14)
{
IRcord[0]=0x00;
mode=2;
}
if(KEY==0) //这里就不用中断0了
{
DelayTime=TimeCount/160;
TimeCount=0; //延时周期计数清零
if(mode==1)
{
du1302(); //读取 秒 分 时 日 月 星 期 年
Scan_Key();
display();
}
if(mode==2)
{
j++;
if(j>432)
{
j=0;
}
for(k=j;k<128+j;k++)
{
P0=zimo[k*2];
P2=zimo[k*2+1];
DelayUs(1);
P0=0XFF;
P2=0XFF;
}
}
}
}
}
/*****END*****/
``
|