版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
#include<reg52.h>#include<lm4229.h>#include<DS1302.h>#include<intrins.h>ucharad_data;ucharch[2];uchards[5];sbitADCS=P3^5;sbitADDI=P3^7;sbitADDO=P3^7;sbitADCLK=P3^6;sbitFUWEI=P3^4;sbitKAISHI=P3^3;floatpress;floatprice;floattotal_price;floatdanjia[]={2.35,3.56,5.67,4.58,8.96,2.65,5.89,2.19};char*mingcheng="商品代码";voiddelay(uintz){ uintx,y; for(x=z;x>0;x--) for(y=110;y>0;y--);}voidbcdtocha(ucharcha){ ch[0]=cha/16+'0'; ch[1]=cha%16+'0';}voidflotocha(floatt){ uinttt; tt=(t*100+0.5); ds[0]=tt/1000+'0'; ds[1]=tt%1000/100+'0'; ds[2]=46; ds[3]=tt%1000%100/10+'0'; ds[4]=tt%10+'0';}/************读ADC0832函数*********** *///采集并返回ucharadc0832()//AD转换,返回结果channel为初始值{ ucharchannel=2;uchari=0;ucharj;uintdat=0;ucharndat=0;ADDI=1;_nop_();_nop_();ADCS=0;//拉低CS端_nop_();_nop_();ADCLK=1;//拉高CLK端_nop_();_nop_();ADCLK=0;//拉低CLK端,形成下降沿1_nop_();_nop_();ADCLK=1;//拉高CLK端ADDI=channel&0x1;_nop_();_nop_();ADCLK=0;//拉低CLK端,形成下降沿2_nop_();_nop_();ADCLK=1;//拉高CLK端ADDI=(channel>>1)&0x1;_nop_();_nop_();ADCLK=0;//拉低CLK端,形成下降沿3ADDI=1;//控制命令结束_nop_();_nop_();dat=0;for(i=0;i<8;i++){dat|=ADDO;//收数据ADCLK=1;_nop_();_nop_();ADCLK=0;//形成一次时钟脉冲_nop_();_nop_();dat<<=1;if(i==7)dat|=ADDO;}for(i=0;i<8;i++){j=0;j=j|ADDO;//收数据ADCLK=1;_nop_();_nop_();ADCLK=0;//形成一次时钟脉冲_nop_();_nop_();j=j<<7;ndat=ndat|j;if(i<7)ndat>>=1;}ADCS=1;//拉搞CS端ADCLK=0;//拉低CLK端ADDO=1;//拉高数据端,回到初始状态dat<<=8;dat|=ndat;return(dat);//returnad}bitfuwei(){ bitcc=1; if(FUWEI==0) { FUWEI=1; delay(10); if(FUWEI==0) cc=0; } returncc;}voiddisp_week(){ gettime_1302(); bcdtocha(year); write_lcd(96,12,ch); bcdtocha(mon); write_lcd(96,16,ch); bcdtocha(day); write_lcd(96,20,ch); bcdtocha(hour); write_lcd(112,0,ch); bcdtocha(min); write_lcd(112,3,ch); bcdtocha(sec); write_lcd(112,6,ch); switch(week) {case1:{write_lcd(112,14,"日");break;} case2:{write_lcd(112,14,"一");break;} case3:{write_lcd(112,14,"二");break;} case4:{write_lcd(112,14,"三");break;}case5:{write_lcd(112,14,"四");break;} case6:{write_lcd(112,14,"五");break;} case7:{write_lcd(112,14,"六");break;} }}voidmain(){EA=1; EX0=1; IT0=1; lcd_init(); init_1302(); clr_lcdall(); write_lcd(0,0,"------------------------------"); write_lcd(12,0,"实用电子称的设计"); write_lcd(28,0,"------------------------------"); write_lcd(40,0,"设计人:张元科"); write_lcd(56,0,"------------------------------"); write_lcd(68,0,"指导教师:姚惠林"); write_lcd(84,0,"------------------------------"); write_lcd(96,0,"当前时间:20年月日"); write_lcd(112,0,"::星期"); do{disp_week(); }while(fuwei()); delay(100); clr_lcdall(); write_lcd(0,0,"商品名称:商品代码"); write_lcd(16,0,"------------------------------"); write_lcd(36,0,"单价:元/千克"); write_lcd(52,0,"重量:千克"); write_lcd(68,0,"总价:元"); write_lcd(84,0,"------------------------------"); write_lcd(96,0,"当前时间:20年月日"); write_lcd(112,0,"::星期"); do{ disp_week(); ad_data=adc0832(); write_lcd(0,9,mingcheng); total_price=price*press; flotocha(price);write_lcd(36,5,ds); flotocha(press); write_lcd(52,5,ds); flotocha(total_price); write_lcd(68,5,ds);}while(fuwei()); delay(100); }voidint0()interrupt0{ P1=0xff; delay(10); switch(P1) { case0xfe: { mingcheng="苹果"; price=danjia[0]; break; } case0xfd: { mingcheng="香蕉"; price=danjia[1]; break; } case0xfb: { mingcheng="黄瓜"; price=danjia[2]; break; } case0xf7: { mingcheng="西瓜"; price=danjia[3]; break; } case0xef: { mingcheng="李子"; price=danjia[4]; break; } case0xdf: { mingcheng="栗子"; price=danjia[5]; break; } case0xbf: { mingcheng="橘子"; price=danjia[6]; break; } case0x7f: { mingcheng="雪梨"; price=danjia[7]; break; } }} typedefstructtypFNT_GB16//汉字字模数据结构{signedcharIndex[2];//汉字内码索引charMsk[32];//点阵码数据};structtypFNT_GB16codeGB_16[]=//数据表{"实",0x01,0x00,0x00,0x80,0x3F,0xFE,0x28,0x04,0x46,0x88,0x04,0x80,0x08,0x80,0x06,0x80,0x04,0x80,0x7F,0xFE,0x00,0x80,0x01,0x40,0x02,0x20,0x04,0x10,0x18,0x18,0x60,0x10,/*0*/"用",0x00,0x00,0x1F,0xFC,0x10,0x84,0x10,0x84,0x10,0x84,0x1F,0xFC,0x10,0x84,0x10,0x84,0x10,0x84,0x1F,0xFC,0x10,0x84,0x10,0x84,0x20,0x84,0x20,0x84,0x40,0x94,0x80,0x88,/*1*/"电",0x01,0x00,0x01,0x00,0x01,0x00,0x3F,0xF8,0x21,0x08,0x21,0x08,0x3F,0xF8,0x21,0x08,0x21,0x08,0x21,0x08,0x3F,0xF8,0x21,0x08,0x01,0x02,0x01,0x02,0x00,0xFE,0x00,0x00,/*2*/ "子",0x00,0x00,0x3F,0xF0,0x00,0x20,0x00,0x40,0x00,0x80,0x01,0x00,0x01,0x00,0x01,0x04,0xFF,0xFE,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x05,0x00,0x02,0x00,/*3*/ "称",0x0C,0x80,0x70,0x80,0x10,0xFE,0x10,0x82,0xFD,0x24,0x31,0x20,0x32,0x20,0x58,0xB0,0x54,0xA8,0x91,0xA4,0x11,0x24,0x12,0x22,0x14,0x22,0x10,0x20,0x10,0xA0,0x10,0x40,/*4*/ "设",0x40,0x00,0x21,0xF0,0x31,0x10,0x21,0x10,0x01,0x10,0x01,0x10,0xE2,0x0E,0x25,0xF8,0x21,0x08,0x21,0x08,0x20,0x90,0x20,0x90,0x28,0x60,0x30,0x90,0x23,0x0E,0x0C,0x04,/*5*/ "计",0x40,0x20,0x20,0x20,0x30,0x20,0x20,0x20,0x00,0x20,0xF3,0xFE,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x12,0x20,0x14,0x20,0x18,0x20,0x10,0x20,0x00,0x20,/*6*/ "人",0x01,0x00,0x01,0x80,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x02,0x80,0x02,0x80,0x04,0x80,0x04,0x40,0x08,0x60,0x08,0x30,0x10,0x18,0x20,0x0E,0x40,0x04,0x00,0x00,/*7*/ "张",0x00,0x80,0xF8,0x88,0x08,0x8C,0x08,0x90,0x78,0xA0,0x40,0xC0,0x40,0x80,0x43,0xFE,0xF8,0xA0,0x48,0xA0,0x08,0x90,0x08,0x90,0x08,0x88,0x08,0xA6,0x29,0xC4,0x10,0x80,/*8*/ "元",0x00,0x00,0x1F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFE,0x04,0x40,0x04,0x40,0x04,0x40,0x04,0x40,0x08,0x40,0x08,0x40,0x10,0x42,0x20,0x42,0x40,0x3E,0x00,0x00,/*9*/ "科",0x06,0x08,0x78,0x88,0x08,0x48,0x08,0x48,0xFE,0x08,0x18,0x88,0x1C,0x48,0x2A,0x48,0x28,0x0E,0x48,0x78,0x8B,0x88,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,/*10*/ "学",0x01,0x08,0x10,0x8C,0x0C,0xC8,0x08,0x90,0x7F,0xFE,0x40,0x04,0x8F,0xE8,0x00,0x40,0x00,0x80,0x7F,0xFE,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x02,0x80,0x01,0x00,/*11*/ "号",0x1F,0xF0,0x10,0x10,0x10,0x10,0x10,0x10,0x1F,0xF0,0x00,0x00,0xFF,0xFE,0x08,0x00,0x08,0x00,0x1F,0xF0,0x08,0x10,0x00,0x10,0x00,0x10,0x01,0x10,0x00,0xA0,0x00,0x40,/*12*/ "指",0x11,0x00,0x11,0x38,0x11,0xC0,0x11,0x04,0xFD,0x04,0x11,0xFC,0x14,0x00,0x19,0xFC,0x31,0x04,0xD1,0x04,0x11,0xFC,0x11,0x04,0x11,0x04,0x11,0x04,0x51,0xFC,0x20,0x00,/*13*/ "导",0x00,0x00,0x1F,0xF0,0x10,0x10,0x1F,0xF0,0x10,0x04,0x10,0x04,0x0F,0xFC,0x00,0x20,0x00,0x20,0xFF,0xFE,0x08,0x20,0x04,0x20,0x06,0x20,0x04,0x20,0x00,0xA0,0x00,0x40,/*14*/ "教",0x08,0x20,0x08,0x20,0x7F,0x20,0x0A,0x7E,0xFF,0xC4,0x08,0x44,0x10,0xC4,0x3E,0x48,0xC4,0x28,0x08,0x28,0x0F,0x10,0xF8,0x10,0x08,0x28,0x08,0xC8,0x2B,0x06,0x10,0x04,/*15*/ "师",0x08,0x00,0x0B,0xFE,0x48,0x20,0x48,0x20,0x4B,0xFE,0x4A,0x22,0x4A,0x22,0x4A,0x22,0x4A,0x22,0x52,0x22,0x52,0x2A,0x12,0x24,0x20,0x20,0x40,0x20,0x80,0x20,0x00,0x20,/*16*/ "姚",0x10,0xA0,0x10,0xA0,0x10,0xA0,0x12,0xA4,0x7D,0xA8,0x24,0xB0,0x24,0xA0,0x24,0xB0,0x49,0xA8,0x2E,0xAC,0x12,0xA8,0x18,0xA0,0x25,0x22,0x41,0x22,0x82,0x1E,0x04,0x00,/*17*/ "惠",0x01,0x00,0x7F,0xFC,0x01,0x00,0x1F,0xF0,0x11,0x10,0x1F,0xF0,0x11,0x10,0x1F,0xF0,0x01,0x08,0x7F,0xFC,0x00,0x04,0x09,0x00,0x28,0x88,0x28,0x24,0x67,0xE4,0x00,0x00,/*18*/ "林",0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0xFD,0xFE,0x10,0x20,0x10,0x60,0x38,0x70,0x34,0xB0,0x54,0xA8,0x51,0x28,0x92,0x26,0x14,0x24,0x10,0x20,0x10,0x20,0x10,0x20,/*19*/ "当",0x00,0x80,0x10,0x90,0x08,0x98,0x0C,0x90,0x08,0xA0,0x00,0x80,0x3F,0xFC,0x00,0x04,0x00,0x04,0x1F,0xFC,0x00,0x04,0x00,0x04,0x00,0x04,0x3F,0xFC,0x00,0x04,0x00,0x00,/*20*/ "前",0x08,0x10,0x06,0x18,0x04,0x20,0xFF,0xFE,0x00,0x00,0x3E,0x08,0x22,0x48,0x3E,0x48,0x22,0x48,0x22,0x48,0x3E,0x48,0x22,0x48,0x22,0x48,0x2A,0x08,0x24,0x28,0x00,0x10,/*21*/ "时",0x00,0x10,0x00,0x10,0x7C,0x10,0x44,0x10,0x47,0xFE,0x44,0x10,0x7C,0x10,0x45,0x10,0x44,0x90,0x44,0x90,0x7C,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x50,0x00,0x20,/*22*/ "间",0x20,0x00,0x13,0xFC,0x10,0x04,0x40,0x04,0x47,0xE4,0x44,0x24,0x44,0x24,0x47,0xE4,0x44,0x24,0x44,0x24,0x47,0xE4,0x40,0x04,0x40,0x04,0x40,0x04,0x40,0x14,0x40,0x08,/*23*/ "年",0x08,0x00,0x0F,0xFC,0x10,0x80,0x10,0x80,0x20,0x80,0x4F,0xF8,0x88,0x80,0x08,0x80,0x08,0x80,0x08,0x80,0xFF,0xFE,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,/*24*/ "月",0x07,0xF0,0x04,0x10,0x04,0x10,0x04,0x10,0x07,0xF0,0x04,0x10,0x04,0x10,0x04,0x10,0x07,0xF0,0x04,0x10,0x08,0x10,0x08,0x10,0x10,0x10,0x20,0x50,0x40,0x20,0x00,0x00,/*25*/ "日",0x00,0x00,0x1F,0xF0,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x1F,0xF0,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x1F,0xF0,0x10,0x10,0x00,0x00,0x00,0x00,/*26*/"星",0x00,0x00,0x1F,0xF8,0x10,0x08,0x1F,0xF8,0x10,0x08,0x1F,0xF8,0x01,0x00,0x11,0x00,0x1F,0xFC,0x21,0x00,0x21,0x00,0x4F,0xF8,0x01,0x00,0x01,0x00,0x7F,0xFE,0x00,0x00,/*0*/ "期",0x22,0x00,0x22,0x7C,0x7F,0x44,0x22,0x44,0x3E,0x44,0x22,0x7C,0x3E,0x44,0x22,0x44,0x22,0x44,0xFF,0x7C,0x00,0x44,0x24,0x84,0x22,0x84,0x43,0x14,0x81,0x08,0x00,0x00,/*1*/ "一",0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x7F,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*2*/ "二",0x00,0x00,0x00,0x10,0x3F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x7F,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,/*3*/ "三",0x00,0x00,0x00,0x00,0x7F,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFE,0x00,0x00,0x00,0x00,/*4*/ "四",0x00,0x00,0x7F,0xFC,0x44,0x84,0x44,0x84,0x44,0x84,0x44,0x84,0x44,0x84,0x44,0x84,0x48,0x84,0x48,0x7C,0x50,0x04,0x60,0x04,0x40,0x04,0x7F,0xFC,0x40,0x04,0x00,0x00,/*5*/ "五",0x00,0x00,0x7F,0xF8,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x20,0x3F,0xF0,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x20,0x04,0x24,0xFF,0xFE,0x00,0x00,0x00,0x00,/*6*/ "六",0x04,0x00,0x03,0x00,0x01,0x80,0x01,0x00,0xFF,0xFE,0x00,0x00,0x00,0x00,0x04,0x80,0x06,0x40,0x04,0x20,0x08,0x10,0x08,0x18,0x10,0x0C,0x20,0x0C,0x40,0x08,0x00,0x00,/*7*/ "商",0x01,0x00,0x00,0x80,0x7F,0xFC,0x04,0x20,0x02,0x40,0x3F,0xF8,0x22,0x48,0x24,0x28,0x3F,0xE8,0x24,0x48,0x24,0x48,0x27,0xC8,0x24,0x48,0x24,0x08,0x20,0x28,0x20,0x10,/*0*/ "品",0x00,0x00,0x0F,0xF0,0x08,0x10,0x08,0x10,0x08,0x10,0x0F,0xF0,0x08,0x10,0x00,0x00,0x7E,0xFC,0x42,0x84,0x42,0x84,0x42,0x84,0x42,0x84,0x7E,0xFC,0x42,0x84,0x00,0x00,/*1*/ "代",0x11,0x00,0x19,0x20,0x11,0x10,0x11,0x08,0x21,0xFC,0x3F,0x00,0x50,0x80,0x90,0x80,0x10,0x80,0x10,0x40,0x10,0x40,0x10,0x24,0x10,0x14,0x10,0x0C,0x10,0x06,0x00,0x00,/*2*/ "码",0x00,0x00,0xFD,0xF8,0x10,0x08,0x10,0x88,0x10,0x88,0x20,0x88,0x3C,0x88,0x64,0xFC,0xA4,0x04,0x24,0x04,0x25,0xF4,0x24,0x04,0x3C,0x04,0x24,0x04,0x20,0x28,0x00,0x10,/*3*/ "单",0x08,0x20,0x06,0x30,0x04,0x40,0x3F,0xF8,0x21,0x08,0x3F,0xF8,0x21,0x08,0x21,0x08,0x3F,0xF8,0x21,0x08,0x01,0x00,0xFF,0xFE,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,/*4*/ "价",0x08,0x40,0x0C,0x40,0x18,0xA0,0x11,0x10,0x32,0x18,0x64,0x0E,0xA9,0x14,0x21,0x10,0x21,0x10,0x21,0x10,0x21,0x10,0x22,0x10,0x22,0x10,0x24,0x10,0x24,0x10,0x28,0x10,/*5*/ "总",0x08,0x20,0x04,0x20,0x04,0x40,0x1F,0xF0,0x10,0x10,0x10,0x10,0x10,0x10,0x1F,0xF0,0x00,0x00,0x01,0x00,0x08,0x88,0x28,0x84,0x28,0x16,0x68,0x12,0x07,0xF0,0x00,0x00,/*6*/ "重",0x01,0xF0,0x3F,0x00,0x01,0x00,0xFF,0xFE,0x01,0x00,0x1F,0xF0,0x11,0x10,0x1F,0xF0,0x11,0x10,0x1F,0xF0,0x01,0x00,0x3F,0xF8,0x01,0x00,0x01,0x00,0xFF,0xFE,0x00,0x00,/*7*/ "量",0x1F,0xF0,0x10,0x10,0x1F,0xF0,0x10,0x10,0x1F,0xF0,0x00,0x00,0xFF,0xFE,0x11,0x10,0x1F,0xF0,0x11,0x10,0x1F,0xF0,0x01,0x00,0x1F,0xF8,0x01,0x00,0xFF,0xFE,0x00,0x00,/*8*/ "苹",0x04,0x40,0x04,0x40,0xFF,0xFE,0x04,0x40,0x04,0x40,0x3F,0xFC,0x11,0x10,0x09,0x18,0x0D,0x20,0x09,0x40,0xFF,0xFE,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,/*9*/ "果",0x00,0x00,0x1F,0xF0,0x11,0x10,0x1F,0xF0,0x11,0x10,0x1F,0xF0,0x01,0x00,0x01,0x00,0xFF,0xFE,0x03,0x80,0x05,0x40,0x09,0x30,0x31,0x0E,0xC1,0x04,0x01,0x00,0x01,0x00,/*10*/ "香",0x01,0xF0,0x3F,0x00,0x01,0x00,0xFF,0xFE,0x03,0x80,0x05,0x40,0x09,0x30,0x31,0x0E,0xCF,0xF4,0x08,0x10,0x08,0x10,0x0F,0xF0,0x08,0x10,0x08,0x10,0x0F,0xF0,0x00,0x00,/*11*/ "蕉",0x04,0x20,0x04,0x20,0xFF,0xFE,0x05,0x20,0x10,0x80,0x1F,0xFC,0x30,0x80,0x5F,0xF8,0x90,0x80,0x1F,0xF8,0x10,0x80,0x1F,0xFC,0x00,0x00,0x28,0x88,0x26,0x66,0x44,0x44,/*12*/ "黄",0x04,0x40,0x04,0x40,0x7F,0xFC,0x04,0x40,0x04,0x40,0xFF,0xFE,0x01,0x00,0x1F,0xF0,0x11,0x10,0x1F,0xF0,0x11,0x10,0x11,0x10,0x1F,0xF0,0x08,0x20,0x10,0x18,0x60,0x08,/*13*/ "西",0x00,0x00,0xFF,0xFE,0x04,0x40,0x04,0x40,0x7F,0xFC,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x44,0x48,0x3C,0x50,0x04,0x60,0x04,0x40,0x04,0x7F,0xFC,0x40,0x04,0x00,0x00,/*15*/ "瓜",0x00,0x10,0x01,0xF8,0x1E,0x40,0x12,0x40,0x12,0x40,0x12,0x20,0x12,0x20,0x12,0x20,0x12,0x20,0x12,0x10,0x12,0x90,0x22,0x50,0x22,0xA8,0x43,0x28,0x42,0x06,0x80,0x04,/*16*/ "李",0x01,0x00,0x01,0x00,0x7F,0xFC,0x03,0x80,0x05,0x40,0x09,0x30,0x31,0x0E,0xDF,0xE4,0x00,0x80,0x01,0x00,0x7F,0xFE,0x01,0x00,0x01,0x00,0x01,0x00,0x05,0x00,0x02,0x00,/*17*/ "子",0x00,0x00,0x3F,0xF0,0x00,0x20,0x00,0x40,0x00,0x80,0x01,0x00,0x01,0x00,0x01,0x04,0xFF,0xFE,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x05,0x00,0x02,0x00,/*18*/ "栗",0x7F,0xFE,0x04,0x40,0x04,0x40,0x3F,0xF8,0x24,0x48,0x24,0x48,0x3F,0xF8,0x01,0x00,0xFF,0xFE,0x01,0x80,0x03,0x40,0x05,0x20,0x19,0x18,0x61,0x0E,0x01,0x04,0x01,0x00,/*19*/ "橘",0x11,0xFC,0x10,0x08,0x10,0x30,0x13,0xFE,0xFC,0x54,0x11,0x90,0x38,0x30,0x37,0xFE,0x52,0x92,0x52,0x8E,0x93,0x72,0x12,0x52,0x12,0x72,0x12,0x02,0x12,0x0A,0x12,0x04,/*21*/ "雪",0x00,0x00,0x3F,0xF8,0x01,0x00,0x7F,0xFE,0x41,0x04,0x1D,0x70,0x01,0x00,0x1D,0x70,0x00,0x00,0x3F,0xF8,0x00,0x08,0x1F,0xF8,0x00,0x08,0x00,0x08,0x3F,0xF8,0x00,0x08,/*23*/ "梨",0x07,0x84,0x7C,0x04,0x04,0x24,0x7F,0xA4,0x0E,0x24,0x15,0x24,0x25,0x04,0xC4,0x14,0x01,0x08,0x7F,0xFE,0x03,0x80,0x05,0x40,0x09,0x30,0x31,0x0E,0xC1,0x04,0x01,0x00,/*24*/ "元",0x00,0x00,0x1F,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0xFE,0x04,0x40,0x04,0x40,0x04,0x40,0x04,0x40,0x08,0x40,0x08,0x40,0x10,0x42,0x20,0x42,0x40,0x3E,0x00,0x00,/*25*/ "千",0x00,0x10,0x00,0xF8,0x3F,0x00,0x01,0x00,0x01,0x00,0x01,0x04,0xFF,0xFE,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x00,0x00,/*26*/ "克",0x01,0x00,0x01,0x00,0x7F,0xFC,0x01,0x00,0x01,0x00,0x1F,0xF0,0x10,0x10,0x10,0x10,0x1F,0xF0,0x14,0x50,0x04,0x40,0x04,0x40,0x08,0x42,0x08,0x42,0x10,0x3E,0x20,0x00,/*27*/ "的",0x10,0x80,0x10,0x80,0x20,0x80,0x7C,0xFC,0x45,0x04,0x45,0x04,0x46,0x04,0x7C,0x84,0x44,0x44,0x44,0x64,0x44,0x24,0x44,0x04,0x7C,0x04,0x44,0x28,0x40,0x10,0x00,0x00,/*0*/"名",0x04,0x00,0x04,0x00,0x07,0xF8,0x08,0x10,0x10,0x20,0x24,0x40,0x42,0x80,0x01,0x00,0x06,0x00,0x1F,0xF8,0xE8,0x08,0x08,0x08,0x08,0x08,0x0F,0xF8,0x08,0x08,0x00,0x00,/*0*/};#ifndefdata_h#definedata_hcharcodeASC_MSK[36*16]={//8*80x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*----*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x3C,0x3C,0x3C,0x18,/*--!--*/0x18,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x66,0x66,0x66,0x00,0x00,/*--"--*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x36,0x7F,0x36,0x36,/*--#--*/0x36,0x7F,0x36,0x36,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x3C,0x66,0x60,0x30,0x18,/*--$--*/0x0C,0x06,0x66,0x3C,0x18,0x18,0x00,0x00,0x00,0x00,0x70,0xD8,0xDA,0x76,0x0C,0x18,/*--%--*/0x30,0x6E,0x5B,0x1B,0x0E,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x6C,0x6C,0x38,0x60,/*--&--*/0x6F,0x66,0x66,0x3B,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x18,0x00,0x00,/*--'--*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x18,0x18,0x30,0x30,/*--(--*/0x30,0x30,0x30,0x18,0x18,0x0C,0x00,0x00,0x00,0x00,0x00,0x30,0x18,0x18,0x0C,0x0C,/*--)--*/0x0C,0x0C,0x0C,0x18,0x18,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x36,0x1C,0x7F,/*--*--*/0x1C,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x7E,/*--+--*/0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*--,--*/0x00,0x00,0x1C,0x1C,0x0C,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,/*-----*/0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*--.--*/0x00,0x00,0x1C,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x0C,0x0C,0x18,/*--/--*/0x18,0x30,0x30,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x1E,0x33,0x37,0x37,0x33,/*--0--*/0x3B,0x3B,0x33,0x1E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x1C,0x7C,0x0C,0x0C,/*--1--*/0x0C,0x0C,0x0C,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x66,0x66,0x06,0x0C,/*--2--*/0x18,0x30,0x60,0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x66,0x66,0x06,0x1C,/*--3--*/0x06,0x66,0x66,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x30,0x36,0x36,0x36,/*--4--*/0x66,0x7F,0x06,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x60,0x60,0x60,0x7C,/*--5--*/0x06,0x06,0x0C,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x18,0x30,0x7C,0x66,/*--6--*/0x66,0x66,0x66,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x06,0x0C,0x0C,0x18,/*--7--*/0x18,0x30,0x30,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x66,0x66,0x76,0x3C,/*--8--*/0x6E,0x66,0x66,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x66,0x66,0x66,0x66,/*--9--*/0x3E,0x0C,0x18,0x38,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x1C,0x00,/*--:--*/0x00,0x00,0x1C,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1C,0x1C,0x00,/*--;--*/0x00,0x00,0x1C,0x1C,0x0C,0x18,0x00,0x00,0x00,0x00,0x00,0x06,0x0C,0x18,0x30,0x60,/*--<--*/0x30,0x18,0x0C,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x00,/*--=--*/0x7E,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x60,0x30,0x18,0x0C,0x06,/*-->--*/0x0C,0x18,0x30,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x66,0x66,0x0C,0x18,/*--?--*/0x18,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0xC3,0xC3,0xCF,0xDB,/*--@--*/0xDB,0xCF,0xC0,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x3C,0x66,0x66,0x66,/*--A--*/0x7E,0x66,0x66,0x66,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x66,0x66,0x66,0x7C,/*--B--*/0x66,0x66,0x66,0x7C,0x00,0x00,0x00,0x00,};#endif/************************************************************************** THEREALTIMERDS1302DRIVERLIB COPYRIGHT(c)2023BYZYK. --ALLRIGHTSRESERVED--FileName:DS1302.hAuthor:ZHANGYUANKECreated:2023/06/21Modified: NORevision: 1.0***************************************************************************/#ifndef_DS1302_2023_06_21_#define_DS1302_2023_06_21_sbitSCLK=P3^0;//实时时钟时钟线引脚sbitDIO=P3^1;//实时时钟数据线引脚sbitCS=P2^7;//实时时钟复位线引脚sbitACC0=ACC^0;sbitACC7=ACC^7;ucharsec,min,hour,day,mon,week,year;voidwrite_1302(ucharadd,uchardat){ uchari; ACC=add; CS=0; SCLK=0; CS=1; for(i=0;i<8;i++) { DIO=ACC0; SCLK=1; SCLK=0; ACC>>=1; } ACC=dat; for(i=0;i<8;i++) { DIO=ACC0; SCLK=1; SCLK=0; ACC>>=1; } CS=0;}ucharread_1302(ucharadd){ uchari; ACC=add; CS=0; SCLK=0; CS=1; for(i=8;i>0;i--)//为什么不能for(i=0;i<8;i++) { DIO=ACC0; SCLK=1; ACC>>=1; SCLK=0; }for(i=8;i>0;i--) { ACC>>=1; ACC7=DIO; SCLK=1; SCLK=0; } return(ACC); CS=0;}/* voidinputbyte(uchard) //实时时钟写入一字节(内部函数){uchari;ACC=d;for(i=8;i>0;i--){DIO=ACC0; //相当于汇编中的RRCSCLK=1;SCLK=0;ACC>>=1;}}ucharoutputbyte() //实时时钟读取一字节(内部函数){uchari;for(i=8;i>0;i--){ACC=ACC>>1; //相当于汇编中的RRCACC7=DIO;SCLK=1;SCLK=0;}return(ACC);}voidwrite_1302(ucharadd,uchardat) //ucAddr:DS1302地址,ucData:要写的数据{CE=0;SCLK=0;CE=1;inputbyte(add); //地址,命令inputbyte(dat); //写1Byte数据CE=0;}ucharread_1302(ucharadd) //读取DS1302某地址的数据{uchardat;CE=0;SCLK=0;CE=1;inputbyte(add);//地址,命令dat=outputbyte();//读1Byte数据CE=0;return(dat);} */voidsetprotect(bitflag){ if(flag) write_1302(0x8e,0x80); else write_1302(0x8e,0x00);}voidsettime_1302(ucharadd,uchardat){ setprotect(0); write_1302(add,((dat/10)<<4)|(dat%10));}voidgettime_1302(){ sec=read_1302(0x81); min=read_1302(0x83); hour=read_1302(0x85); day=read_1302(0x87); mon=read_1302(0x89); week=read_1302(0x8b); year=read_1302(0x8d);}voidinit_1302(){ ucharsecond=read_1302(0x81); if(second&0x80) settime_1302(0x80,0);}/********************************************************************************voidBurstWrite1302(unsignedchar*pWClock) //往DS1302写入时钟数据(多字节方式){unsignedchari;Write1302(0x8e,0x00); //控制命令,WP=0,写操作?DS1302_RST=0;DS1302_CLK=0;DS1302_RST=1;DS1302InputByte(0xbe); //0xbe:时钟多字节写命令for(i=8;i>0;i--) //8Byte=7Byte时钟数据+1Byte控制{DS1302InputByte(*pWClock); //写1Byte数据pWClock++;}DS1302_CLK=1;DS1302_RST=0;}voidBurstRead1302(unsignedchar*pRClock) //读取DS1302时钟数据(时钟多字节方式){unsignedchari;DS1302_RST=0;DS1302_CLK=0;DS1302_RST=1;DS1302InputByte(0xbf); //0xbf:时钟多字节读命令for(i=8;i>0;i--){*pRClock=DS1302OutputByte();//读1Byte数据pRClock++;}DS1302_CLK=1;DS1302_RST=0;}voidDS1302_TimeStop(bitflag)//是否将时钟停止{ unsignedcharData; Data=Read1302(DS1302_SECOND); DS1302_SetProtect(0); if(flag) Write1302(DS1302_SECOND,Data|0x80); else Write1302(DS1302_SECOND,Data&0x7F);}********************************************************************************/#endif#include<reg52.h>#defineucharunsignedchar#defineuintunsignedint#defineDATA_PORTP0sbitHALT=P2^0;sbitFS1=P2^1;//字体模式选择sbitMD2=P2^2;//方式选择sbitRST=P2^3;//复位sbitCD=P2^4;//数据(L)/命令(H)选择sbitWRIT=P2^5;
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2022幼儿园大班社会领域教学方案10篇
- 玻璃纤维薄片项目年终总结报告
- 民兵应急分队组织实施应急演练
- 石河子大学《市场调查与预测实训》2023-2024学年第一学期期末试卷
- 石河子大学《建筑设计》2022-2023学年第一学期期末试卷
- 石河子大学《复变函数与积分变换》2022-2023学年第一学期期末试卷
- 沈阳理工大学《最优控制》2022-2023学年期末试卷
- 沈阳理工大学《室内设计原理》2021-2022学年第一学期期末试卷
- 酿酒机器行业分析研究报告
- 糖糖尿病足的护理
- 2024江苏省沿海开发集团限公司招聘23人高频难、易错点500题模拟试题附带答案详解
- 2024年计算机二级WPS考试题库380题(含答案)
- 22G101三维彩色立体图集
- 大学生安全文化智慧树知到期末考试答案章节答案2024年中南大学
- 建筑施工安全生产治本攻坚三年行动方案(2024-2026年)
- 人教版小学英语单词表(完整版)
- DL-T 1476-2023 电力安全工器具预防性试验规程
- 国家开放大学《心理健康教育》形考任务1-9参考答案
- MOOC 法理学-西南政法大学 中国大学慕课答案
- 《短视频拍摄与制作》课件-3短视频拍摄的三大技巧
- 【川教版】《生命 生态 安全》四上第11课《预防流感》课件
评论
0/150
提交评论