资源描述:
《低频信号产生波形》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、#includesbitCH452_SCL=P1^3;sbitCH452_SDA=P1^4;sbitCH452_KEY=P1^5;unsignedcharsecond0,second1,minute0,minute1,f,j;//四个参数unsignedchartc,sta=0x08,stb=0x01;//软件延时单元,状态标志codeunsignedchards=0x14;//软件延时系数__20bitflag1=0;unsignedchark,dispbuff[]={0,0,0,0,0,0,0,0};//显示缓冲,初始显示全0unsignedintC
2、MD,DAT,DAT1;unsignedcharbuffer[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,};codeunsignedcharfont[32]={0xFC,0x60,0xDA,0xF2,0x66,0xB6,0xBE,0xE0,//012345670xFE,0xF6,0xEE,0x3E,0x9C,0x7A,0x9E,0x8E,//89ABCDEF0xFD,0x61,0xDB,0xF3,0x67,0xB7,0xBF,0xE1,//0.1.2.3.4.5.6.7.0xFF,0xF7
3、,0x00,0x62,0x02,0x12,0x7C,0x1C};//8.9.灭+—=ULcodeunsignedcharkey[16]={0xC6,0xB6,0x86,0xD6,0x96,0xA6,0xF6,0xE6,0xC4,0xB4,0x84,0xD4,0x94,0xA4,0xF4,0xE4};//键盘位置码codeunsignedinttable1[4][32]={4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,4095,0,0,0,0,0,0,0,0,0,0,0,0,0,
4、0,0,0,0,256,512,768,1024,1280,1536,1792,2048,2304,2560,2816,3072,3328,3584,3840,4095,3840,3584,3328,3072,2816,2560,2304,2048,1792,1536,1280,1024,768,512,256,2048,2447,2831,3185,3496,3750,3940,4056,4095,4057,3941,3752,3498,3188,2834,2451,2051,1652,1268,913,603,348,158,40,0,38,154,342,596,905,1
5、259,1642,0,132,264,396,528,660,792,924,1056,1188,1320,1452,1584,1716,1848,1980,2112,2244,2376,2508,2640,2772,2904,3036,3168,3300,3432,3564,3696,3828,3960,4092};//二维数组(方波,锯齿波,正弦波,三角波)/*mS延时*/voiddelayms(unsignedinti){unsignedintj;do{for(j=0;j!=1000;j++){;}}while(--i);}/////////////////////////
6、/////////////////////////////////////////////////////////////*uS延时*/voiddelayus(void){unsignedintk;for(k=0;k<8;k++){;}}unsignedcharrdch452(void){unsignedcharj,key;CH452_SDA=0;delayus();CH452_SCL=0;delayus();CH452_SCL=1;delayus();CH452_SCL=0;key=0x9F;for(j=0;j<8;j++){if(key>=0x80)CH452_SDA=1;e
7、lseCH452_SDA=0;CH452_SCL=1;delayus();CH452_SCL=0;key=key<<1;};delayus();key=0;for(j=0;j<8;j++){CH452_SCL=1;if(CH452_SDA==1)key++;key=key<<1;CH452_SCL=0;delayus();}CH452_SDA=1;delayus();CH452_SCL=1;returnkey;}//////////////////////////////////