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

專注電子技術學習與研究
當前位置:單片機教程網 >> MCU設計實例 >> 瀏覽文章

MSP430f2272單片機中斷控制4X4鍵盤程序

作者:未知   來源:山澗一溪流   點擊數:  更新時間: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;
   } 
 }
關閉窗口

相關文章

主站蜘蛛池模板: 国产精品视频一区二区三区 | 国产欧美精品 | 久久精品国产99国产精品亚洲 | 国产99久久 | 国产视频精品区 | 国产精品第2页 | 亚洲在线免费 | 91精品国产综合久久小仙女图片 | 国产日韩欧美一区二区 | 超碰97人人人人人蜜桃 | 一区在线观看视频 | 99国内精品久久久久久久 | 99久久婷婷国产综合精品 | 欧美一区二区三区在线 | 国产黄色小视频在线观看 | 亚洲国产69 | 欧美视频中文字幕 | 黄免费观看视频 | 日本久久精品视频 | 国产精品久久国产精品99 | 男女视频在线观看免费 | 一区二区三区在线免费观看 | 亚洲高清电影 | 久久久99国产精品免费 | 免费看国产一级特黄aaaa大片 | 中文字幕第二区 | 久久久国产一区二区三区 | 国内精品视频免费观看 | 亚洲免费一区 | 国产精品久久久久久久久图文区 | 91高清在线观看 | 亚洲精品一二三区 | 日韩成人免费视频 | 久久国产精品免费一区二区三区 | 亚洲精品麻豆 | 国产精品爱久久久久久久 | 亚洲一区 中文字幕 | 亚洲精品免费观看 | 成人亚洲视频 | 欧美日韩成人在线 | 日韩三区在线观看 |