欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標(biāo)題: 51單片機中斷,含源程序,代碼 [打印本頁]

作者: Mr-L    時間: 2018-11-18 18:01
標(biāo)題: 51單片機中斷,含源程序,代碼
中斷程序代碼
對初學(xué)者很有幫助
在學(xué)校實驗中得過驗證
運用proteus和keil軟件進行呈現(xiàn)



  1. #include<reg51.h>
  2. #include<intrins.h>

  3. sbit K2 = P3^2;
  4. sbit K3 = P3^3;

  5. void delayms(unsigned int m);
  6. unsigned char  aa = 0xfe;

  7. void main()
  8. {
  9.         EA = 1;
  10.         EX0 = 1;
  11.         EX1 = 1;
  12.         IT0 = 1;  //跳變沿觸發(fā)方式
  13.         IT1 = 1;  // 打開INT0的中斷允許
  14.         IP = 0xf1;
  15.         P1 = 0xff;
  16. }

  17. /*低級的外部中斷2,負(fù)責(zé)按鈕1 的操作,即實現(xiàn)流水燈*/
  18. void button_1() interrupt 2
  19. {               
  20.         if(K3 == 0)
  21.         {
  22.                  delayms(10);
  23.                 if(K3 == 0)
  24.                 {
  25.                         while(1)
  26.                         {       
  27.                                 P1 = aa;
  28.                                 aa = _crol_(aa,1);
  29.                                 delayms(500);
  30.                         }       
  31.                 }
  32.         }
  33.                                                
  34. }

  35. /*外部中斷0(最高級),負(fù)責(zé)打斷外部中斷 2*/
  36. void button_2() interrupt 0
  37. {
  38.         if(K2 == 0)
  39.         {
  40.                 delayms(10);
  41.                 if(K2 == 0)
  42.                 {
  43.                        
  44.                         while(1)
  45.                         ;
  46.                        
  47.                 }
  48.         }
  49.                        
  50. }

  51. void delayms(unsigned int m)
  52. {
  53.         unsigned int i, j;
  54.         for(i = m; i > 0; i--)
  55.         {
  56.                 for(j = 110; j > 0; j--)
  57.                 ;
  58.         }
  59. }
復(fù)制代碼
中斷.docx (108.77 KB, 下載次數(shù): 38)









歡迎光臨 (http://www.raoushi.com/bbs/) Powered by Discuz! X3.1