📄 intt.c
字号:
/*********************************************************************
* Filename: intt.c *
* Date: 10/22/2002 *
* Edit by Yamato View ,Goldenchip Electronic Co. ,Ltd. *
* *
* TEL: 86-0591-3375855-721 *
* *
*********************************************************************/
#include <pic1687x.h>
#include <stdio.h>
extern char Intdata;
extern char Rtcdata;
unsigned char Rtcsign;
#define PortBit(port,bit) ((unsigned)&(port)*8+(bit))
unsigned char Alarm_1;
unsigned char Alarm_2;
unsigned char Alarm_3;
unsigned char Dminutes;
unsigned char Dhours;
unsigned char MOD;
unsigned char Alarm_1_hour;
unsigned char Alarm_1_min ;
unsigned char Alarm_2_hour;
unsigned char Alarm_2_min ;
unsigned char Alarm_3_hour;
unsigned char Alarm_3_min ;
extern char hours,minutes,days,monthes,years;
extern char daysLmt;
extern void Line_1( void );
extern void Line_2( void );
extern void Home_Clr( void );
extern void Time_Disp1(void);
extern void Time_Disp2(void);
extern void Line_C6( void );
extern void Line_C9( void );
extern void Line_8C( void );
extern void Line_85( void );
extern void Line_88( void );
extern void Line_8A( void );
extern void Dayscount(void);
extern void Delay15Ms( void );
extern void Tm1_Update( void );
void Init_Timer0(void)
{
TMR0 = 0xFF;
T0IE = 1;
INTE = 1;
T0IF = 0;
}
void Note1( void )
{
Line_2();
printf("INT to Enter");
}
void Note2( void )
{
Line_1();
printf("SetAlarm");
}
void Note3( void )
{
Line_1();
printf("Exit Setup");
Line_2();
printf("INT to Exit ");
}
void Time_Adj_S( void )
{
if (Rtcdata==4)
{
Line_C6();
printf(" ");
if (Intdata == 1)
hours++;
if(hours>23)
hours = 0;
Intdata = 0;
}
if (Rtcdata==5)
{
Line_C9();
printf(" ");
if (Intdata == 1)
minutes++;
if(minutes>59)
minutes = 0;
Intdata = 0;
}
if (Rtcdata==6)
{
Line_8C();
printf(" ");
if (Intdata == 1)
{
Rtcdata = 0;
Intdata = 0;
if (Rtcsign == 2)
Alarm_1 = 0;
if (Rtcsign == 3)
Alarm_2 = 0;
if (Rtcsign == 4)
Alarm_3 = 0;
}
}
}
void Rtcdeal1(void)
{
Rtcdata = 1;
Intdata = 0;
while(Rtcdata>0)
{
Time_Disp1();
Time_Disp2();
Line_8C();
printf("Ext.");
if (Rtcdata==1)
{
Line_1();
printf(" ");
if (Intdata == 1)
years++;
if(years>99)
years = 0;
Intdata = 0;
}
if (Rtcdata==2)
{
Line_85();
printf(" ");
if (Intdata == 1)
monthes++;
if(monthes>12)
monthes = 1;
Intdata = 0;
}
if (Rtcdata==3)
{
Line_88();
printf(" ");
if (Intdata == 1)
{
Dayscount();
if(days<daysLmt)
days++;
else days = 1;
}
Intdata = 0;
}
Delay15Ms();
Delay15Ms();
Delay15Ms();
Time_Adj_S();
if (Rtcdata>6) Rtcdata = 1;
}
Rtcdata = (Rtcsign+1);
Rtcsign = 0;
}
void Rtcdeal2(void)
{
Rtcdata = 4;
Intdata = 0;
Dhours = hours;
Dminutes = minutes;
while(Rtcdata>3)
{
unsigned char Sna;
Sna = (Rtcsign-1);
Note2();
printf("%d",Sna);
Line_8A();
printf("Y Ext."); //159
Time_Disp2();
Delay15Ms() ;
Delay15Ms() ;
Delay15Ms() ;
Time_Adj_S();
if (Rtcdata==7)
{
Line_8A();
printf(" ");
if (Intdata == 1)
{
if (Rtcsign == 2)
{
Alarm_1 = 1;
Alarm_1_hour = hours;
Alarm_1_min = minutes;
}
if (Rtcsign == 3)
{
Alarm_2 = 1;
Alarm_2_hour = hours;
Alarm_2_min = minutes;
}
if (Rtcsign == 4)
{
Alarm_3 = 1;
Alarm_3_hour = hours;
Alarm_3_min = minutes;
}
Rtcdata = 0;
Intdata = 0;
}
}
if (Rtcdata>7) Rtcdata = 4;
}
Rtcdata = (Rtcsign+1);
Rtcsign = 0;
hours = Dhours;
minutes = Dminutes;
Home_Clr();
}
void Intn(void)
{
while (Rtcdata>0)
{
Intdata = 0;
Home_Clr();
while (Rtcdata==1)
{
Line_1();
printf("Set Time");
Note1();
if (Intdata==1)
{
Rtcsign = 1;
Home_Clr();
Rtcdeal1();
}
}
while (Rtcdata==2)
{
Note2();
printf("1 ");
Note1();
if (Intdata==1)
{
Rtcsign = 2;
Home_Clr();
Rtcdeal2();
}
}
while (Rtcdata==3)
{
Note2();
printf("2 ");
Note1();
if (Intdata==1)
{
Rtcsign = 3;
Rtcdeal2();
Home_Clr();
}
}
while (Rtcdata==4)
{
Note2();
printf("3 ");
Note1();
if (Intdata==1)
{
Rtcsign = 4;
Home_Clr();
Rtcdeal2();
}
}
while (Rtcdata==5)
{
Note3();
if(Intdata==1)
{
Intdata = 0;
Rtcsign = 0;
Rtcdata = 0;
}
}
if (Rtcdata>5) Rtcdata=1;
}
}
void Flash(void)
{
TRISD = 0;
MOD=(MOD<<1);
if ( CARRY==1 )
MOD++;
PORTD= MOD;
Tm1_Update();
Time_Disp2();
}
void Aladisp(void)
{
unsigned char Alr_Done;
if(Alarm_1==1)
{
MOD = 0x0f;
while (hours == Alarm_2_hour&&minutes==Alarm_1_min)
{
Flash();
}
}
Alr_Done = 0;
if(Alarm_2==1)
{
MOD = 3;
while (hours == Alarm_2_hour&&minutes==Alarm_2_min)
{
Flash();
}
}
if(Alarm_3==1)
{
MOD = 0x3f;
while (hours == Alarm_3_hour&&minutes==Alarm_3_min)
{
Flash();
}
}
PORTD = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -