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;
}
}
上一篇:STC12系列读取DS1302间断乱码
下一篇:verilog同步复位PK异步复位
推荐阅读最新更新时间:2024-03-16 13:51