[mw_shl_code=c,true]#include <reg51.h>
#include <intrins.h>
#define uchar unsigned char
#define uint unsigned int
#define DelayNOP() {_nop_();_nop_();_nop_();_nop_();}
sbit K1=P1^0;
sbit K2=P1^1;
sbit K3=P1^2;
sbit K4=P1^3;
sbit SPK=P3^0;
sbit LCD_RS=P2^0;
sbit LCD_RW=P2^1;
sbit LCD_EN=P2^2;
bit LCD_Busy_Check();
void LCD_Initialize();
void LCD_Set_POS(uchar);
void LCD_Write_Command(uchar);
void LCD_Write_Data(uchar);
uchar code string1[]=" Current Time ";
uchar code string2[]="Set New Time ...";
bit Settime=0;
bit Change_H_or_M=1;
uchar MilliSecond,Hour=12,Minute=30,Second=0;
void DelayMS(uint x)
{
uchar i;
while(x--) for(i=0;i<120;i++);
}
void Display_String(uchar * str,uchar LineNo)
{
uchar k;
LCD_Set_POS(LineNo);
for(k=0;k<16;k++) LCD_Write_Data(str[k]);
}
void Beep()
{
char i,j=70;
for(i=0;i<200;i++)
{
while(--j);SPK=~SPK;
}
DelayMS(300);SPK=0;
}
void Display_HMS(uchar h,m,s)
{
if(Settime)
HMS_String[3]='>';
else
HMS_String[3]='';
HMS_String[4]=h/10+'0';
HMS_String[5]=h%10+'0';
HMS_String[7]=m/10+'0';
HMS_String[8]=m%10+'0';
HMS_String[10]=s/10+'0';
HMS_String[11]=s%10+'0';
Display_String(HMS_String,0x40);
}
void Change_Time()
{
Settime=0;
if(K1==0||K2==0||K3==0)
{
TR0=0;
Display_String(string2,0x00);
Settime=1;
}
while(Settime)
{
if(K1==0)
{
Beep();
while(K1==0);
Change_H_or_M=!Change_H_or_M;
}
else if(K2==0)
{
Beep();
while(K2==0);
if(Change_H_or_M==1)
{if(++Hour==24)Hour=0;}
else
{if(++Minute==60)Minute=0;}
}
else if(K3==0)
{
Beep();
while(K3==0);
if(Change_H_or_M==1)
{if(--Hour=0xff)Hour=23;}
else
{if(--Minute==0xff)Minute=59;}
}
else if(K4==0)
{
Beep();
while(K4==0);
Display_String(string1,0x00);
Settime=0;
TR0=1;
}
Display_HMS(Hour,Minute,Second);
}
}
void Time0() interrupt 1
{
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
if(++Second==20)
{
Second=0;
if(++Minute==60)
{
Minute=0;
if(++Hour==24)
{
Hour=0;Minute=0;Second=0;
}
}
}
}
void main()
{
TMOD=0x01;
TH0=(65536-50000)/256;
TL0=(65536-50000)%256;
IE=0x82;
SPK=0;
LCD_Initialize();
Display_String(string1,0x00);
TR0=1;
P1=0xFF;
while(1)
{
Display_HMS(Hour,Minute,Second);
DelayMS(500);
Change_Time();
}
}[/mw_shl_code]
Build target 'Target 1'
assembling STARTUP.A51...
compiling clock.c...
CLOCK.C(48): error C202: 'HMS_String': undefined identifier
CLOCK.C(50): error C202: 'HMS_String': undefined identifier
CLOCK.C(50): error C101: '''': invalid character constant
CLOCK.C(51): error C202: 'HMS_String': undefined identifier
CLOCK.C(52): error C202: 'HMS_String': undefined identifier
CLOCK.C(53): error C202: 'HMS_String': undefined identifier
CLOCK.C(54): error C202: 'HMS_String': undefined identifier
CLOCK.C(55): error C202: 'HMS_String': undefined identifier
CLOCK.C(56): error C202: 'HMS_String': undefined identifier
CLOCK.C(57): error C202: 'HMS_String': undefined identifier
Target not created
|