这编译错误该怎么解决啊?球大虾帮忙啊.... compiling ds1302时钟点阵显示.c... DS1302时钟点阵显示.C(40): error C141: syntax error near 'void' DS1302时钟点阵显示.C(41): error C141: syntax error near '{' DS1302时钟点阵显示.C(42): error C231: 'TMOD': redefinition DS1302时钟点阵显示.C(43): error C231: 'TH0': redefinition DS1302时钟点阵显示.C(43): error C231: 'TH0': redefinition DS1302时钟点阵显示.C(44): error C231: 'TL0': redefinition DS1302时钟点阵显示.C(44): error C231: 'TL0': redefinition DS1302时钟点阵显示.C(46): error C231: 'ET0': redefinition DS1302时钟点阵显示.C(46): error C231: 'ET0': redefinition DS1302时钟点阵显示.C(47): error C231: 'TR0': redefinition DS1302时钟点阵显示.C(47): error C231: 'TR0': redefinition DS1302时钟点阵显示.C(48): error C141: syntax error near '}' ds1302时钟点阵显示.c - 12 Error(s), 0 Warning(s). #include<reg52.h> #define uchar unsigned char #define uint unsigned int sbit rst=P0^0; sbit sclk=P0^1; sbit io=P0^2; #define sclk_H sclk=1 //时钟信号 #define sclk_L sclk=0 #define rst_H rst=1 //复位信号 #define rst_L rst=0 #define io_H io=1 //双向数据 #define io_L io=0 #define IO io #define ds1302_sec_add 0x80 //秒数据地址 #define ds1302_min_add 0x82 //分数据地址 #define ds1302_hr_add 0x84 //时数据地址 #define ds1302_date_add 0x86 //日数据地址 #define ds1302_month_add 0x88 //月数据地址 #define ds1302_day_add 0x8a //星期数据地址 #define ds1302_year_add 0x8c //年数据地址 #define ds1302_control_add 0x8e //控制数据地址 #define ds1302_charger_add 0x90 //涓电流地址 #define ds1302_clkburst_add 0xbe uchar time_tab1[]={12,4,11,3,22,19,0}; uchar time_tab[7]; /********向ds1302写一字节数据*********/ void ds1302_write_byte(uchar add,uchar date) { uchar i; rst_H; //写入地址 add&=0xfe; for(i=0;i<8;i++) { if(add&0x01) { io_H; } else { io_L; } sclk_H; sclk_L; add>>=1; } //写入数据 for(i=0;i<8;i++) { if(date&0x01) { io_H; } else { io_L; } sclk_H; sclk_L; date>>=1; } rst_L; // } /*************从ds1302读一字节数据*************/ uchar ds1302_read_byte(uchar add) { uchar i,temp; //写入地址 add|=0x01; for(i=0;i<8;i++) { if(add&0x01) { io_H; } else { io_L; } sclk_H; sclk_L; add>>=1; } //读数据 for(i=0;i<8;i++) { if(IO) { temp|=0x80; } else { temp&=0x7f; } sclk_H; sclk_L; temp>>=1; } rst_L; return temp; } /**************向ds1302写入时钟*****************/ void ds1302_write_time() { uchar i,j,k; for(i=0;i<7;i++) { j=time_tab1/10; //10进制转BCD k=time_tab1%10; time_tab=j*16+k; } ds1302_write_byte(ds1302_control_add,0x00); //写入打开 ds1302_write_byte(ds1302_sec_add,0x80); //时间暂停 ds1302_write_byte(ds1302_year_add,time_tab[0]); //年 ds1302_write_byte(ds1302_month_add,time_tab[1]); //月 ds1302_write_byte(ds1302_date_add,time_tab[2]); //日 ds1302_write_byte(ds1302_day_add,time_tab[3]); //周 ds1302_write_byte(ds1302_hr_add,time_tab[4]); //时 ds1302_write_byte(ds1302_min_add,time_tab[5]); //分 ds1302_write_byte(ds1302_sec_add,time_tab[6]); //秒 ds1302_write_byte(ds1302_control_add,0x80); //写入禁止 } /****************从ds1302读出时钟******************/ void ds1302_read_time() { uchar i,j,k; time_tab[0]=ds1302_read_byte(ds1302_year_add); //年 time_tab[1]=ds1302_read_byte(ds1302_month_add); //月 time_tab[2]=ds1302_read_byte(ds1302_date_add); //日 time_tab[3]=ds1302_read_byte(ds1302_day_add); //周 time_tab[4]=ds1302_read_byte(ds1302_hr_add); //时 time_tab[5]=ds1302_read_byte(ds1302_min_add); //分 time_tab[6]=ds1302_read_byte(ds1302_sec_add); //秒 for(i=0;i<7;i++) { j=time_tab/16; //BCD转10进制 k=time_tab%16; time_tab=j*10+k; } } /************ds1302初始化*****************/ void INIT_ds1302() { rst_L; sclk_L; ds1302_write_byte(ds1302_sec_add,0x00); } #include<reg52.h> #include"ds1302.c" #define uchar unsigned char #define uint unsigned int #define con P1 sbit G=P1^6; sbit st_595=P1^7;
uchar dis_tab[4*32]; uchar code shu_tab[][16]= { /********0(0) 1(1) 2(2) 3(3) 4(4) 5(5) 6(6) 7(7) 8(8) 9(9) :(:)**************/ {0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18,0x00,0x00},/*"0",0*/ {0x00,0x00,0x00,0x08,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00},/*"1",1*/ {0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x20,0x20,0x10,0x08,0x04,0x42,0x7E,0x00,0x00},/*"2",2*/ {0x00,0x00,0x00,0x3C,0x42,0x42,0x20,0x18,0x20,0x40,0x40,0x42,0x22,0x1C,0x00,0x00},/*"3",3*/ {0x00,0x00,0x00,0x20,0x30,0x28,0x24,0x24,0x22,0x22,0x7E,0x20,0x20,0x78,0x00,0x00},/*"4",4*/ {0x00,0x00,0x00,0x7E,0x02,0x02,0x02,0x1A,0x26,0x40,0x40,0x42,0x22,0x1C,0x00,0x00},/*"5",5*/ {0x00,0x00,0x00,0x38,0x24,0x02,0x02,0x1A,0x26,0x42,0x42,0x42,0x24,0x18,0x00,0x00},/*"6",6*/ {0x00,0x00,0x00,0x7E,0x22,0x22,0x10,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00},/*"7",7*/ {0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x24,0x18,0x24,0x42,0x42,0x42,0x3C,0x00,0x00},/*"8",8*/ {0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x64,0x58,0x40,0x40,0x24,0x1C,0x00,0x00},/*"9",9*/ {0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00} /*":",:*/ } void INIT_time_0() { TMOD|=0x01; TH0=(65536-20000)/256; TL0=(65536-20000)%256; // EA=1; ET0=1; TR0=1; } void _time_0() interrupt 1 /*************点阵显示扫描***************/ { uchar m,n=0; TH0=(65536-20000)/256; TL0=(65536-20000)%256; m=con; m=++m&0x0f; //屏蔽高4位 if(n<8) { n++; SBUF=dis_tab[m*2+(n/2)*32+(n%2)]; while(!TI); TI=0; } G=1; con&=0xf0; st_595=1; con|=m; st_595=0; G=0; } void INIT_time_1() { TMOD|=0X10; TH1=(65536-23000)/256; TL1=(65536-23000)%256; // EA=1; ET1=1; TR1=1; } void _time_1() interrupt 3 { uchar i; TH1=(65536-23000)/256; TL1=(65536-23000)%256; ds1302_read_time(); for(i=0;i<16;i++) { dis_tab[i*2]=shu_tab[time_tab[4]/10]; dis_tab[i*2+1]=shu_tab[time_tab[4]%10]; } for(i=0;i<16;i++) { dis_tab[32+i*2]=shu_tab[10]; dis_tab[32+i*2+1]=shu_tab[time_tab[5]/10]; } for(i=0;i<16;i++) { dis_tab[64+i*2]=shu_tab[time_tab[5]%10]; dis_tab[64+i*2+1]=shu_tab[10]; } for(i=0;i<16;i++) { dis_tab[96+i*2]=shu_tab[time_tab[6]/10]; dis_tab[96+i*2+1]=shu_tab[time_tab[6]%10]; } } /***************主函数*******************/ void main() { // EA=1; INIT_time_0(); INIT_time_1(); INIT_ds1302(); SCON=0X00; con=0xff; /* EA=1; INIT_time_0(); INIT_time_1(); INIT_ds1302(); */ while(1); } |