📄 msp430fwc.c
字号:
//delay(255);
//delay(255);
//flashmaintry();
//}
TBCTL|=TBIE;
//checkcard(); //首先进行IC卡的检查并进行相应的显示
P6SEL=0X20;
ADC12CTL0&=~ENC; //stop a/d change
ADC12CTL0 = ADC12ON+REFON+REF2_5V+SHT0_8;
ADC12CTL1 = SHP; // Use sampling timer
ADC12MCTL0 = SREF_1+INCH_5; // Vr+ = VeREF+ (external)
ADC12CTL0 |= ENC;
mainloop:
while(1)
{
delay(10);
checkcard();
mainloop1: P3OUT|=BIT0;
//P3OUT&=~BIT0; //关断外部电源
m=0;
exitjsq=0;
while((P1IN&BIT2)==0)
{
jcqy();
//P3OUT&=~BIT0; //关断外部电源
_EINT();
FLAG2|=BIT3; //
//delay(200); //延时60ms
ycsjre64();
//if((P2IN&BIT1)==0)
//m++;
//else m=0; //如果按下确认键则m一直加一,否则m=0
if(((P1IN&BIT2)==0)&&(exitjsq>700)) //如果插卡且时间超过600ms
{
disp_lcd(0,0,0,0,0);
tljish = 0;
//timeoverf = 0;
FLAG&=~BIT5;
//testend_led = 1;
P5OUT&=~BIT0;
/*prep_led = 0;*/
P5OUT|=BIT2;
FLAG|=BIT3; //////////建立插卡测试标志位
FLAG2&=~BIT3; //////////清除空闲标志
delay(200); //延时60ms
ycsjre64();
goto next_test;
}
}
m=0;
disp_lcd(0xd,0xd,0xd,0xd,0x0);
while((P1IN&BIT2)!=0)
{
jcqy();
//P3OUT&=~BIT0; //关断外部电源
FLAG2|=BIT3; //
P5OUT&=~BIT1;
//delay(200); //延时60ms
//if((P2IN&BIT1)==0)
//m++;
//else m=0; //如果按下确认键则m一直加一,否则m=0
P5OUT&=~BIT0;
P5OUT&=~BIT2;
P5OUT|=BIT3;
if(exitjsq>100)
{
disp_lcd(0,0,0,0,0);
tljish = 0;
//timeoverf = 0;
FLAG&=~BIT5;
//testend_led = 1;
P5OUT&=~BIT0;
P5OUT&=~BIT1;
P5OUT&=~BIT3;
/*prep_led = 0;*/
P5OUT|=BIT2;
FLAG2&=~BIT3; //////////清除空闲标志
FLAG&=~BIT3; //////////建立插卡测试标志位
delay(200); //延时60ms
ycsjre64();
goto next_test;
}
}
goto mainloop;
}
next_test: P3OUT|=BIT0; //打开外部电源
m=0;
sound_s();
ywqzjsq=0x00;
exitjsq=0;
while(ywqzjsq<3000) //延时等待
{
//delay(200);
if(ywqzjsq==0x05) sound_s();
if (exitjsq >100)
{
exitjsq=0;
//TR0 = 0;
TACTL&=~MC1; //定时器暂停
//EX0 = 0;
P2IE&=~BIT6; //
//EX1 = 0;
P2IE&=~BIT7; //禁止外部中断
tljish = 0;
//int0f = 0;
FLAG&=~BIT6;
//int1f = 0;
FLAG&=~BIT7;
//timeoverf = 0;
FLAG&=~BIT5;
delay(200);
delay(200);
goto testend;
}
if(((P1IN&BIT2)!=0)&&((FLAG&BIT3)!=0))
{
//TR0 = 0;
TACTL&=~MC1; //定时器暂停
//EX0 = 0;
P2IE&=~BIT6; //
//EX1 = 0;
P2IE&=~BIT7; //禁止外部中断
tljish = 0;
//int0f = 0;
FLAG&=~BIT6;
//int1f = 0;
FLAG&=~BIT7;
//timeoverf = 0;
FLAG&=~BIT5;
goto testend;
}
}
delay(200);
delay(200);
delay(200);
delay(200);
//sound_s();
for (i=0;i<=5;i++)
{
for (j=0;j<=5;j++)
{
delay(200);
//if (card_sw == 1)
if((P1IN&BIT2!= 0)&&(FLAG&BIT3!=0))
{
delay(240);
//if (card_sw == 1)
if((P1IN&BIT2!=0)&&(FLAG&BIT3!=0))
{
//TR0 = 0;
TACTL&=~MC1; //定时器暂停
//EX0 = 0;
P2IE&=~BIT6; //
//EX1 = 0;
P2IE&=~BIT7; //禁止外部中断
tljish = 0;
//int0f = 0;
FLAG&=~BIT6;
//int1f = 0;
FLAG&=~BIT7;
//timeoverf = 0;
FLAG&=~BIT5;
goto testend;
}
}
}
}
/////////////////////////////
/*prep_led = 1;*/
P5OUT|=BIT1;
/*test_led = 0;*/ //测试开始
P5OUT&=~BIT2;
dotime = 0;
disp1 = 6;
disp2 = 0;
disp3 = 0;
IC_error = 0;
//int0f = 0;
FLAG&=~BIT6;
//int1f = 0;
FLAG&=~BIT7;
FLAG&=~BIT5; ///////////////////
sound_star();
TAR=0X3caf; //初始化定时器内容
//TAR=0X5629;
P2IFG&=~BIT7;
/*ET0 = 1;
TR0 = 1;
IT0 = 1;
EX0 = 1;
IT0 = 1;
IT1 = 1;
EX1 = 1;
IT1 = 1;*/
TACTL|=TAIE+MC1; //允许定时器中断,允许定时器开始工作
P2IE|=BIT7; //开启外部中断
//firstnum = 0;
FLAG&=~BIT4;
//while (timeoverf == 0)
//while (timeoverf == 0)
exitjsq=0;
breaknum=50;
while((FLAG&BIT5)==0)//////////////////////////////////////////////////////////////////
{
delay(10);
if((FLAG&BIT3)!=0)
{
delay(10);
if((P1IN&BIT2)==0) goto loop4;
delay(200);
//TR0 = 0;
TACTL&=~MC1; //定时器暂停工作
//EX0 = 0;
//EX1 = 0;
P2IE&=~(BIT6+BIT7); //禁止外部中断
tljish = 0;
//int0f = 0;
FLAG&=~BIT6;
//int1f = 0;
FLAG&=~BIT7;
//timeoverf = 0;
FLAG&=~BIT5;
goto testend;
}
loop4: delay(10);
if (breaknum == 0)
{
breaknum = 50;
//TR0 = 0;
TACTL&=~MC1; //定时器暂停工作
goto endend;
}
if (exitjsq >700)
{
exitjsq=0;
//TR0 = 0;
TACTL&=~MC1; //定时器暂停工作
delay(200);
delay(200);
goto testend;
}
if((FLAG&BIT7)!=0)
{
//int1f = 0;
FLAG&=~BIT7;
dotime++;
sound_s();
}
if (breaknum == 0)
if ((FLAG&BIT6)==0)
{
breaknum = 50;
//TR0 = 0;
TACTL&=~MC1; //定时器暂停工作
break;
}
else
{
breaknum = 50;
//int0f = 0;
//int0f = 0;
FLAG&=~BIT6;
}
if ((FLAG&BIT6)==0)
{
breaknum--;
delay(200);
delay(100);
}
if((P2IN&BIT7)==0) breaknum=50;
}
endend:
//EX0 = 0;
//EX1 = 0;
FLAG&=~BIT3; /////////////////////
P2IE&=~(BIT6+BIT7);
b = dotime;
/////////////////////////////
HEX_BCD(b);
disp_lcd(0,BCD[5],BCD[6],BCD[7],0);
//test_led = 1;
//P5OUT&=~BIT2;
//testend_led = 0;
//P5OUT|=BIT3;
delay(255);
sound_s();
delay(255);
delay(255);
FLAG&=~BIT3;
if((P1IN&BIT2) != 0)
{
/*incard_led = 1;*/
P5OUT|=BIT0;
/*test_led = 1;*/
P5OUT&=~BIT3;
/*incard_led = 1;*/
P5OUT&=~BIT2;
/*testend_led = 0;*/
P5OUT&=~BIT1;
for(i=0;i<50;i++)
delay(200);
goto testend;
}
delay(255);
delay(255);
delay(255);
delay(255);
//while (card_sw == 1)//是否插卡
FK_error1:
a=0;
while ((P1IN&BIT2) != 0)
{
FK_error:
disp_lcd(0x0c,0x0c,0x0c,0x0c,0);
//EA = 0;
_DINT();
sound_s();
//EA = 1;
_EINT();
delay(255);
delay(255);
delay(255);
a++;
if (a == 5)
{
disp_lcd(0,0,0,0,0);
delay(255);
delay(255);
delay(255);
goto testend;
}
}
IC_error = 0;
a = IC_read(0x00);
if (IC_error == 0xff)
{
sound_s();
goto FK_error; //卡查反
}
IC_error = 0;//
disp_lcd(0x0d,0x0a,0x0a,0x0d,0);
for(b=1;b<3;b++)
{//
delay(255);
delay(200);
disp_lcd(0x0e,0x0e,0x0e,0x0e,0);
delay(255);
delay(200);
disp_lcd(0x0d,0x0a,0x0a,0x0d,0);
}//
a = (BCD[6]<<4)+BCD[7];
IC_write(FYS_save1,a);
delay(20);
a = BCD[5];
IC_write(FYS_save0,a);
delay(20);
IC_write(FYS_flag,1);
delay(20);
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lsbuf=(uint)(re1byte(0x00));
lsbuf=(uint)(lsbuf*256+re1byte(0x01));
if(lsbuf>2700)
{
for(i=0;i<50;i++)
delay(200);
goto testend;
}
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
////////////////////////////////////////////////////////////
readicid(); //读取卡号
result[0]=0x00;
result[1]=0x00;
result[2]=BCD[5];
result[3]=(BCD[6]<<4)+BCD[7];
FLAG2|=BIT0; //置数据有标志,可进行发送
//disp_lcd(0x01,0x01,0x01,0x01,0);
for(i=0;i<5;i++)
delay(200);
FLAG2&=~BIT0;
lsbuf=(uint)(re1byte(0x00));
lsbuf=(uint)(lsbuf*256+re1byte(0x01));
for(ii=0;ii<8;ii++)
{
temp=icidbuf[ii];
wr1byte(0x40+12*lsbuf+ii,temp);
delay(50);
}
for(ii=0;ii<4;ii++)
{
temp=result[ii];
wr1byte(0x40+12*lsbuf+8+ii,temp);
delay(50);
}
lsbuf++;
at64count++;
temp=(uchar)(lsbuf/256);
wr1byte(0x00,temp);
delay(50);
temp=(uchar)(lsbuf%256);
wr1byte(0x01,temp);
delay(50);
////////////////////////////////////////////////////////////
a = IC_read(FYS_save0);
disp1 = a;
a = IC_read(FYS_save1);
disp2 = a>>4;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -