资源描述:
《单片机原理与C51程序设计基础教程 教学课件 作者 978-7-302-23075-5第12章.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、填空题1.双键互锁方式和N键巡回方式2.动态静态3.直插式贴片式4.中断方式5.段控信号位控信号选择题1.b2.c3.AB4.B5B上机题1.#include"reg51.h"unsignedcharcodeTAB[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xbf,0xff};chardisp[2][4]={{2008},{0315}};voiddelay1ms(int);voidscanner(char);main(){char
2、i;while(1){for(i=0;i<2;i++){scanner(i);P1=0xff;delay1ms(480);}}}voiddelay1ms(intx){inti,j;for(i=0;i3、;delay1ms(4);scan>>=1;}}}2.#include"reg51.h"#defineSEGP2#defineSCANPP1sbitLED=P0^&;#definecount_M150000#defineTH_M1(65536-COUNT_M1)/256#defineTH_M1(65536-COUNT_M1)%256intcount_T0=0;#definecount_M2250#defineTH_M2(256-count_M2)unsignedcharcodeTAB[]={0x
4、c0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xbf,0xff};chardisp[2]={0xc0,0xc0};charseconds=0;charscan=0;main(){IE=0X8A;TMOD=0X21;TH0=TH_M1;TL0=TL_M1;TR0=1;TH1=TH_M2;TL0=TL_M2;TR1=1;LED=1;while(1);}voidT01s(void)interrupt1{TH0=TH_M1;TL0=TL_M1;if(+
5、+count_T0==20){count_T0=0;seconds++;if(++count_T0==20){count_T0=0;seconds++;if(seconds==60){seconds=0;LED=~LED;}}disp[1]=TAB[second/10];disp[0]=TAB[second%10];}}voidT1_8ms(void)interrupt3{if(++count_T1==32){count_T1=0;if(++scan==3)scan=1;SEG=0XFF;SCA
6、NP=~scan;SEG=disp[scan-1];}}3.#include"reg51.h"unsignedcharcodeTAB[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0xbf,0xff};#definecounts6chardisp[counts+7]={10,10,10,10,1,2,3,4,5,6,10,10,10};voiddelay1m(int);voidscanner(char);main(){chari;whi
7、le(1)for(i=0;i>=1;}}}