资源描述:
《单片机流程图》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、单片机总流程图NDisp_HELLO();结束i=o?YDisp_HELLO();NDisp_HELLO();主函数程序#include#include#defineucharunsignedchar#defineuintunsignedint#defineO
2、SC_FREQ12000000#define__10ms(65536-OSC_FREQ/(12000000/9970))#defineCOM8255XBYTE[0XFFF3]#definePA8255XBYTE[0XFFF0]#definePB8255XBYTE[0XFFF1]#definePC8255XBYTE[0XFFF2]ucharcodetab[]={0xFC,0x60,0xDA,0xF2,0x66,0xB6,0xBE,0xE0,0xFE,0xF6};ucharcodedis_HELLO[]={0
3、x89,0x86,0xc7,0xc7};ucharcodedis_op51[]={0xc0,0x8c,0x92,0xf9};ucharcodedis_code[]={0xcf,0xa4,0xcf,0xa4};ucharucCnt_10ms=99;uchari=0;ucharJ=0;ucharn=0;ucharled1;ucharled2;sbitP2_4=P2^4;sbitP3_7=P3^7;sbitP1_0=P1^0;sbitP1_1=P1^1;sbitP1_2=P1^2;voidDisp_op51()
4、;voidDisp_HELLO();voidSet_Init_Xint();voidSet_Init_Timer();voidDisp_t();voidDelayX1ms(uintcount);voidDisp_8255();voidmain(){for(;;){Set_Init_Xint();Set_Init_Timer();Disp_8255();//ucCnt_10ms=99;//ucLed1=6;//ucLed2=8;if(n>=1){for(;;){Disp_HELLO();if(PB8255=
5、=0xef){for(;;){Disp_op51();Disp_t();for(i=0;i<0xff;i++);}}for(i=0;i<0xff;i++);}}}}定时器T0流程图开始NY定时器T0计时YucCnt_10ms=0ucCnt_10ms==200?定时器中断服务函数重装初值TR0=1?植入初值定时器T0初始化中断返回结束定时器初始化函数程序voidSet_Init_Timer(){TMOD=0x01;TH0=__10ms/256;TL0=__10ms%256;EA=1;ET0=1;}定时器中断
6、服务函数程序Run_Time0(void)interrupt1using2{TR0=0;TH0=__10ms/256;TL0=__10ms%256;TR0=1;ucCnt_10ms++;if(ucCnt_10ms==200)//1s{ucCnt_10ms=0;led1++;if(led1==10)//1S时间到更新显示缓冲值{led1=0;led2++;}if(led2==10){led2=0;}}}外部中断0流程图开始Y结束TR0=1,n++=中断服务程序中断返回外部中断0初始化是否有中断请求?外部中断
7、初始化函数程序voidSet_Init_Xint(){IT0=1;EX0=1;EA=1;}定时器中断服务函数程序Run_Xint0(void)interrupt0using1{n++;TR0=1;}独立式按键流程图开始YNY结束i<0xff?0~99函数OP51函数PB8255==0xef?(K12)8255初始化定义ABC口8255入口地址8255定义入口#defineCOM8255XBYTE[0XFFF3]#definePA8255XBYTE[0XFFF0]#definePB8255XBYTE[0XF
8、FF1]#definePC8255XBYTE[0XFFF2]sbitP3_7=P3^7;sbitP1_0=P1^0;sbitP1_1=P1^1;sbitP1_2=P1^2;8255初始化函数程序voidDisp_8255(){P3_7=0;P1_0=0;P1_1=1;P1_2=0;COM8255=0x82;}HELLO显示函数程序voidDisp_HELLO()//HELLO显示函数{SCON=0x00;SBUF=0xFC;P