这个程序用来实现液晶时钟,编译时出" error C193: '/': bad operand type",请问错在那里啊,怎么该这个错。
程序如下:
#include <reg52.h>
#include <absacc.h>
#include <intrins.h>
#define uchar unsigned char
#define unit unsigned int
sbit T_CLK = P1^3;
sbit T_IO = P1^4;
sbit T_RST = P1^2;
sbit RS = P1^7;
sbit RW = P1^6;
sbit EN = P1^5;
sbit key0 = P3^0;
sbit key1 = P3^1;
sbit key3 = P3^2;
sbit ACC7 = ACC^7;
sbit ACC0 = ACC^0;
uchar datechar[] = {"DATE:"};
uchar
timechar[] = {"TIME:"};
uchar datebuffer[8] = {0,0,0x2d,0,0,0x2d,0,0};
uchar timebuffer[8] = {0,0,0x3a,0,0,0x3a,0,0};
uchar data ttime[3] = {0x00,0x00,0x00};
uchar data tdata[3] = {0x00,0x00,0x00};
void WriteB(uchar ucDa)
{
uchar i;
ACC = ucDa;
for(i=8;i>0;i--)
{
T_IO = ACC0;
T_CLK = 1;
T_CLK = 0;
ACC = ACC >> 1;
}
}
uchar ReadB(void)
{
uchar i;
for(i=8;i>0;i--)
{
ACC = ACC >> 1;
ACC7 = T_IO;
T_CLK = 1;
T_CLK = 0;
}
return(ACC);
}
void V_W1302(uchar ucAddr,uchar ucDa)
{
T_RST = 0;
T_CLK = 0;
_nop_ ();
_nop_();
T_RST = 1;
_nop_();
_nop_();
WriteB(ucAddr);
WriteB(ucDa);
T_CLK = 1;
T_RST = 0;
}
uchar uc_R1302(uchar ucAddr)
{
uchar ucDa = 0;
T_RST = 0;
T_CLK = 0;
T_RST = 1;
WriteB(ucAddr);
ucDa = ReadeB();
T_CLK = 1;
T_RES = 0;
return(ucDa);
}
void fbusy()
{
P2 = 0xff;
RS = 0;
RW = 1;
EN = 1;
EN = 0;
while((P2 & 0x80))
{
EN = 0;
EN = 1;
}
}
void wc51r(uchar j)
{
fbusy();
EN = 0;
RS = 0;
RW = 0;
EN = 1;
P2 = j;
EN = 0;
}
void wc51ddr(uchar j)
{
fbusy();
EN = 0;
RS = 1;
RW = 0;
EN = 1;
P2 = j;
EN = 0;
}
void init()
{
wc51r(0x01);
wc51r(0x38);
wc51r(0x0c);
wc51r(0x06);
}
void delay(uint i)
{
uint y,j;
for(j=0;j<i;j++)
{
for(y=0;y<0xff;y++){;}
}
}
void main(void)
{
uchar i,set;
uchar data temp;
SP = 0x50;
delay(10);
init();
wc51r(0x80);
for(i=0;i<5;i++)
wc51ddr(datechar[i]);
wc51r(0xc0);
for(i=0;i<5;i++)
wc51ddr(timechar[i]);
while(1)
{
P3 = 0xFF;
if(key0 == 0)
{
delay(10);
if(key0 == 0)
{
while(key0 == 0);
set++;
if(set == 6) set=0;
}
}
if(key1 == 0)
{
delay(10);
if(key1 == 0)
{
while(key1 == 0);
switch(set)
{
case 1:
tdata[0]++;
if(tdata[0] == 100)
tdata[0] = 0;
temp = (tdata[0]/10)*16 + tdata[0]%10;
V_W1302(0x8e,0);
V_W1302(0x8c,temp);
V_W1302(0x8e,0x80);
break;
case 2:
tdata[1]++;
if(tdata[1] == 13)
tdata[1] = 1;
temp = (tdata[1]/10)*16 + tdata[1]%10;
V_W1302(0x8e,0);
V_W1302(0x88,temp);
V_W1302(0x8e,0x80);
break;
case 3:
tdata[2]++;
if(tdata[2] == 32)
tdata[2] = 1;
temp = (tdata[2]/10)*16 + tdata[2]%10;
V_W1302(0x8e,0);
V_W1302(0x86,temp);
V_W1302(0x8e,0x80);
break;
case 4:
ttime[2]++;
if(ttime[2] == 24)
ttime[2] = 0;
temp = (ttime[2]/10)*16 + ttime[2]%10;
V_W1302(0x8e,0);
V_W1302(0x84,temp);
V_W1302(0x8e,0x80);
break;
case 5:
ttime[1]++;
if(ttime[1] == 60)
ttime[1] = 0;
temp = (ttime[1]/10)*16 + ttime[1]%10;
V_W1302(0x8e,0);
V_W1302(0x82,temp);
V_W1302(0x8e,0x80);
break;
}
}
}
if(key2 == 0)
{
delay(10);
if(key2 == 0)
{
while(key2 == 0);
switch(set)
{
case 1:
tdata[0]--;
if(tdata[0] == 0xff)
tdata[0] = 99;
temp = (tdata[0]/10)*16 + tdata[0]%10;
V_W1302(0x8e,0);
V_W1302(0x8c,temp);
V_W1302(0x8e,0x80);
break;
case 2:
tdata[1]--;
if(tdata[1] == 0x00)
tdata[1] = 12;
temp = (tdata[1]/10)*16 + tdata[1]%10;
V_W1302(0x8e,0);
V_W1302(0x88,temp);
V_W1302(0x8e,0x80);
break;
case 3:
tdata[2]--;
if(tdata[2] == 0x00)
tdata[2] = 31;
temp = (tdata[2]/10)*16 + tdata[2]%10;
V_W1302(0x8e,0);
V_W1302(0x86,temp);
V_W1302(0x8e,0x80);
break;
case 4:
ttime[2]--;
if(ttime[2] == 0xff)
ttime[2] = 23;
temp = (ttime[2]/10)*16 + ttime[2]%10;
V_W1302(0x8e,0);
V_W1302(0x84,temp);
V_W1302(0x8e,0x80);
break;
case 5:
ttime[1]--;
if(ttime[1] == 0xff)
ttime[1] = 59;
temp = (ttime[1]/10)*16 + ttime[1]%10;
V_W1302(0x8e,0);
V_W1302(0x82,temp);
V_W1302(0x8e,0x80);
break;
}
}
}
temp = uc_R1302(0x8d);
tdata[0] = (temp/16)*10 + temp%16;
datebuffer[0] = 0x30 + temp/16;
datebuffer[1] = 0x30 + temp%16;
temp = uc_R1302(0x89);
tdata[1] = (temp/16)*10 + temp%16;
datebuffer[3] = 0x30 + temp/16;
datebuffer[4] = 0x30 + temp%16;
temp = uc_R1302(0x87);
tdata[2] = (temp/16)*10 + temp%16;
datebuffer[6] = 0x30 + temp/16;
datebuffer[7] = 0x30 + temp%16;
temp = uc_R1302(0x85);
temp = temp & 0x7f;
ttime[2] = (temp/16)*10 + temp%16;
timebuffer[0] = 0x30 + temp/16;
timebuffer[1] = 0x30 + temp%16;
temp = uc_R1302(0x83);
ttime[1] = (temp/16)*10 + temp%16;
timebuffer[3] = 0x30 + temp/16;
timebuffer[4] = 0x30 + temp%16;
temp = uc_R1302(0x81);
temp = temp & 0x7f;
ttime[0] = (temp/16)*10 + temp%16;
timebuffer[6] = 0x30 + temp/16;
timebuffer[7] = 0x30 + temp%16;
wc51r(0x86);
for(i=0;i<8;i++) wc51addr(datebuffer[i]);
wc51r(0xc6);
for(i=0;i<8;i++) wc51ddr(timebuffer[i]);
}
}
我查了很久都找不到数据类型在那错的。
一周热门 更多>