久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

專注電子技術(shù)學(xué)習(xí)與研究
當(dāng)前位置:單片機(jī)教程網(wǎng) >> MCU設(shè)計(jì)實(shí)例 >> 瀏覽文章

MSP430f2272單片機(jī)中斷控制4X4鍵盤程序

作者:未知   來源:山澗一溪流   點(diǎn)擊數(shù):  更新時(shí)間:2014年06月22日   【字體:
#include "msp430f2272.h"
int yu[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
          0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
int i,j,k,temp,dat,ms;
void delay(int ms)
{
  while(ms--)
   for(i=0;i<2;i++);
}
int main( void )
{
  // Stop watchdog timer to prevent time out reset
  WDTCTL = WDTPW + WDTHOLD;
  P1DIR |=0x0f;    
  P2DIR  =0xff;  
   P1IE  |=0xf0;   
  P1IES |=0xf0;   
  P2OUT=yu[0];     
  P1IFG =0x00;
  _EINT(); 
  temp=0xfe;
  while(1)
  {
    temp=0xfe;
    P1OUT=temp;
    delay(5);
    temp=0xfd;
    P1OUT=temp;
    delay(5);
    temp=0xfb;
    P1OUT=temp;
    delay(5);
    temp=0xf7;
    P1OUT=temp;
    delay(5);
  }
}
 #pragma   vector=PORT1_VECTOR
 __interrupt void Port_ISR(void)
 {   
   switch(temp)
       {
           case 0xfe:
             {
               if(P1IFG==BIT4)dat=0;
               if(P1IFG==BIT5)dat=1;
               if(P1IFG==BIT6)dat=2;
               if(P1IFG==BIT7)dat=3;
               P2OUT =~yu[dat];
               P1IFG=0x00;
               break;
             }
           case 0xfd:
             {
               if(P1IFG==BIT4)dat=4;
               if(P1IFG==BIT5)dat=5;
               if(P1IFG==BIT6)dat=6;
               if(P1IFG==BIT7)dat=7;
               P2OUT =~yu[dat];
               P1IFG=0x00;
               break;
             }
           case 0xfb:
             {
               if(P1IFG==BIT4)dat=8;
               if(P1IFG==BIT5)dat=9;
               if(P1IFG==BIT6)dat=10;
               if(P1IFG==BIT7)dat=11;
                P2OUT =~yu[dat];
                P1IFG=0x00;
                break;
              }
           case 0xf7:
             {
               if(P1IFG==BIT4)dat=12;
               if(P1IFG==BIT5)dat=13;
               if(P1IFG==BIT6)dat=14;
               if(P1IFG==BIT7)dat=15;
                P2OUT =~yu[dat];
                P1IFG=0x00;
                break;
             }
           default:break;
       } 
 }
/*********************************************************/
#include "msp430f2272.h"
int yu[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
          0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
int i,j,k,temp,dat,ms;
void delay(int ms)
{
  while(ms--)
   for(i=0;i<2;i++);
}
int main( void )
{
  // Stop watchdog timer to prevent time out reset
  WDTCTL = WDTPW + WDTHOLD;
  P1DIR |=0x0f;    
  P2DIR  =0xff;   
  P1REN |=0xf0;
  P1IE  |=0xf0;   
  P1IES |=0xf0;  
  P2OUT=~yu[6];     
  P1IFG =0x00;
  _EINT();
  temp=0xfe;
  while(1)
  {
    temp=0xfe;
    P1OUT=temp;
    delay(5);
    temp=0xfd;
    P1OUT=temp;
    delay(5);
    temp=0xfb;
    P1OUT=temp;
    delay(5);
    temp=0xf7;
    P1OUT=temp;
    delay(5);
  }
}
 #pragma   vector=PORT1_VECTOR
 __interrupt void Port_ISR(void)
 {   
   switch(temp)
       {
           case 0xfe:
             {
               if((P1IFG|0xef)==0xff)dat=0;
               if((P1IFG|0xdf)==0xff)dat=1;
               if((P1IFG|0xbf)==0xff)dat=2;
               if((P1IFG|0x7f)==0xff)dat=3;
               P2OUT =~yu[dat];
               P1IFG=0x00;
               break;
             }
           case 0xfd:
             {
               if((P1IFG|0xef)==0xff)dat=4;
               if((P1IFG|0xdf)==0xff)dat=5;
               if((P1IFG|0xbf)==0xff)dat=6;
               if((P1IFG|0x7f)==0xff)dat=7;
               P2OUT =~yu[dat];
               P1IFG=0x00;
               break;
             }
           case 0xfb:
             {
                if((P1IFG|0xef)==0xff)dat=8;
                if((P1IFG|0xdf)==0xff)dat=9;
                if((P1IFG|0xbf)==0xff)dat=10;
                if((P1IFG|0x7f)==0xff)dat=11;
                P2OUT =~yu[dat];
                P1IFG=0x00;
                break;
              }
           case 0xf7:
             {
                if((P1IFG|0xef)==0xff)dat=12;
                if((P1IFG|0xdf)==0xff)dat=13;
                if((P1IFG|0xbf)==0xff)dat=14;
                if((P1IFG|0x7f)==0xff)dat=15;
                P2OUT =~yu[dat];
                P1IFG=0x00;
                break;
             }
           default:break;
       } 
 }

 #include "msp430f2272.h"
int yu[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
          0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
int i,j,k,temp,dat,ms;
void delay(int ms)
{
  while(ms--)
   for(i=0;i<2;i++);
}
int main( void )
{
  // Stop watchdog timer to prevent time out reset
  WDTCTL = WDTPW + WDTHOLD;
  P1DIR |=0x0f;    
  P2DIR  =0xff;    
  P1REN |=0xf0;
  P1IE  |=0xf0;    
  P1IES |=0xf0;  
  P2OUT=~yu[6];     
  P1IFG =0x00;
  _EINT();
  temp=0xfe;
  while(1)
  {
    temp=0xfe;
    P1OUT=temp;
    delay(5);
    temp=0xfd;
    P1OUT=temp;
    delay(5);
    temp=0xfb;
    P1OUT=temp;
    delay(5);
    temp=0xf7;
    P1OUT=temp;
    delay(5);
  }
}
 #pragma   vector=PORT1_VECTOR
 __interrupt void Port_ISR(void)
 {   
   if(temp==0xfe)
   {
            if((P1IFG|0xef)==0xff)dat=0;
            if((P1IFG|0xdf)==0xff)dat=1;
            if((P1IFG|0xbf)==0xff)dat=2;
            if((P1IFG|0x7f)==0xff)dat=3;
            P2OUT =~yu[dat];
            P1IFG=0x00;
   }
      if(temp==0xfd)
   {
            if((P1IFG|0xef)==0xff)dat=4;
            if((P1IFG|0xdf)==0xff)dat=5;
            if((P1IFG|0xbf)==0xff)dat=6;
            if((P1IFG|0x7f)==0xff)dat=7;
            P2OUT =~yu[dat];
            P1IFG=0x00;
   }
         if(temp==0xfb)
   {
            if((P1IFG|0xef)==0xff)dat=8;
            if((P1IFG|0xdf)==0xff)dat=9;
            if((P1IFG|0xbf)==0xff)dat=10;
            if((P1IFG|0x7f)==0xff)dat=11;
            P2OUT =~yu[dat];
            P1IFG=0x00;
   }
         if(temp==0xf7)
   {
            if((P1IFG|0xef)==0xff)dat=12;
            if((P1IFG|0xdf)==0xff)dat=13;
            if((P1IFG|0xbf)==0xff)dat=14;
            if((P1IFG|0x7f)==0xff)dat=15;
            P2OUT =~yu[dat];
            P1IFG=0x00;
   } 
 }
關(guān)閉窗口

相關(guān)文章

主站蜘蛛池模板: 亚洲一区二区免费看 | 亚洲精品成人 | 国产精品免费在线 | 久久99久久99精品免视看婷婷 | 久久精品一 | 久久亚洲视频网 | 日韩中文字幕一区 | 中文字幕一区二区在线观看 | 日本三级全黄三级a | 国产黄色在线观看 | 天堂视频免费 | 久久国 | 国产精品大全 | 日韩中文字幕一区 | 在线观看www | 91福利在线观看 | 国产一区二区精 | 久久tv在线观看 | 国产精品日韩欧美一区二区三区 | 国产乱码精品1区2区3区 | 国产一区二区中文字幕 | 国产.com | 日本天天操 | 国产农村一级国产农村 | 国产精品毛片一区二区在线看 | 中文字幕一级 | 国产成人精品久久久 | 国产传媒在线播放 | 欧美亚洲国语精品一区二区 | 激情五月婷婷在线 | 91精品国产综合久久小仙女图片 | 久久午夜视频 | 日韩色图在线观看 | 国产精彩视频在线观看 | 色综合天天天天做夜夜夜夜做 | 99在线观看| 91视频大全 | 欧美1页 | 免费在线性爱视频 | 国产亚洲区 | 国产精品成人一区二区三区 |