#include <msp430f249.h>
#define uchar unsigned char
#define uint unsigned int
uchar const led_tab[]={
0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
0x7f,0x6f};
uchar key;
void delayus(uint t)
{
uint i;
while(t--)
for(i=2000;i>0;i--);
}
void system_Initial(void)
{
P1DIR=0XFF;
P2DIR=BIT0+BIT1;
P1OUT=0X00;
P2OUT=BIT0+BIT1;
P2IE |=BIT2;
P2IES |=BIT2;
P2IFG &= ~BIT2;
_EINT();
}
#pragma vector=PORT2_VECTOR
__interrupt void Port_2(void)
{
P2IFG &= ~BIT2;
key=0x01;
}
void main( void )
{
uchar i;
uchar count=30;
uchar disp_buf[2];
WDTCTL = WDTPW + WDTHOLD;
system_Initial();
while(1)
{
if(key ==0x01)
{
key=0;
_DINT();
for(count=30;count>0;count--)
{
disp_buf[1]=count/10;
disp_buf[0]=count%10;
for(i=0;i<25;i++)
{
P1OUT=0;
P1OUT=led_tab[disp_buf[1]];
P2OUT= ~BIT0;
delayus(2000);
P1OUT=0;
P1OUT=led_tab[disp_buf[0]];
P2OUT= ~BIT1;
delayus(2000);
}
}
P1OUT=led_tab[0];
P2OUT= ~BIT1;
_EINT();
}
}
}
程序报错:Warning[Pe069]: integer conversion resulted in truncation C:UsersAdministratorDesktop2位一体数码管倒计时main.c 54
此帖出自
小平头技术问答
一周热门 更多>