本人用的是远翔FEELING FM8PE531MA,现在写C程序跨页时遇到问题。
void Kg_Handler(void)
{
if(kg_count>160)
{
kg_count=0;
if(PB1)
{
if(flag1)
{
flag1=0;
flag2=1;
Led_Clear();
}
kg_flag=1;
}
else
{
if(flag2)
{
flag2=0;
flag1=1;
Led_Clear();
}
kg_flag=0;
}
}
}
void chang_pwm(u8 dt) @0x650
{
if(i<=0)
j=1;
if(i>=30)
j=-1;
if(udata1)
{
udata1=0;
i=i+j;
}
if(kg_flag)
{
switch(10-dt)
{
case 1:dat9=i;/*dat8=i;dat7=i;dat6=i;dat5=i;dat4=i;dat3=i;dat2=i;dat1=i;*/break;
case 2:dat8=i;/*dat9=0;dat7=i;dat6=i;dat5=i;dat4=i;dat3=i;dat2=i;dat1=i;*/break;
case 3:dat9=0;dat8=0;dat7=i;dat6=i;dat5=i;dat4=i;dat3=i;dat2=i;dat1=i;break;
case 4:dat9=0;dat8=0;dat7=0;dat6=i;dat5=i;dat4=i;dat3=i;dat2=i;dat1=i;break;
case 5:dat9=0;dat8=0;dat7=0;dat6=0;dat5=i;dat4=i;dat3=i;dat2=i;dat1=i;break;
case 6:dat9=0;dat8=0;dat7=0;dat6=0;dat5=0;dat4=i;dat3=i;dat2=i;dat1=i;break;
case 7:dat9=0;dat8=0;dat7=0;dat6=0;dat5=0;dat4=0;dat3=i;dat2=i;dat1=i;break;
case 8:dat9=0;dat8=0;dat7=0;dat6=0;dat5=0;dat4=0;dat3=0;dat2=i;dat1=i;break;
case 9:dat9=0;dat8=0;dat7=0;dat6=0;dat5=0;dat4=0;dat3=0;dat2=0;dat1=i;break;
default:
break;
}
}
else
{
switch(10-dt)
{
case 1:dat1=i;/*dat2=i;dat3=i;dat4=i;dat5=i;dat6=i;dat7=i;dat8=i;dat9=i;*/break;
case 2:dat2=i;/*dat1=0;dat3=i;dat4=i;dat5=i;dat6=i;dat7=i;dat8=i;dat9=i;*/break;
case 3:dat1=0;dat2=0;dat3=i;dat4=i;dat5=i;dat6=i;dat7=i;dat8=i;dat9=i;break;
case 4:dat1=0;dat2=0;dat3=0;dat4=i;dat5=i;dat6=i;dat7=i;dat8=i;dat9=i;break;
case 5:dat1=0;dat2=0;dat3=0;dat4=0;dat5=i;dat6=i;dat7=i;dat8=i;dat9=i;break;
case 6:dat1=0;dat2=0;dat3=0;dat4=0;dat5=0;dat6=i;dat7=i;dat8=i;dat9=i;break;
case 7:dat1=0;dat2=0;dat3=0;dat4=0;dat5=0;dat6=0;dat7=i;dat8=i;dat9=i;break;
case 8:dat1=0;dat2=0;dat3=0;dat4=0;dat5=0;dat6=0;dat7=0;dat8=i;dat9=i;break;
case 9:dat1=0;dat2=0;dat3=0;dat4=0;dat5=0;dat6=0;dat7=0;dat8=0;dat9=i;break;
default:
break;
}
}
P0DPR=dat1;
P1DPR=dat3;
}
void CTR_FLAME_Pwm(void) @0x450
{
STATUSbits.PG0=1;
switch(sta)
{
case 1:
chang_pwm(1);
break;
case 2:
chang_pwm(2);
break;
case 3:
chang_pwm(3);
break;
case 4:
chang_pwm(1);
break;
case 5:
chang_pwm(2);
break;
case 6:
chang_pwm(4);
break;
case 7:
chang_pwm(5);
break;
case 8:
chang_pwm(2);
break;
case 9:
chang_pwm(3);
break;
case 10:
chang_pwm(5);
break;
case 11:
chang_pwm(6);
break;
case 12:
chang_pwm(7);
break;
case 13:
chang_pwm(6);
break;
case 14:
chang_pwm(5);
break;
case 15:
chang_pwm(4);
break;
case 16:
chang_pwm(2);
break;
case 17:
chang_pwm(4);
break;
case 18:
chang_pwm(5);
break;
case 19:
chang_pwm(7);
break;
case 20:
chang_pwm(8);
break;
case 21:
chang_pwm(9);
break;
case 22:
chang_pwm(7);
break;
case 23:
chang_pwm(5);
break;
case 24:
chang_pwm(4);
break;
case 25:
chang_pwm(3);
break;
case 26:
chang_pwm(4);
break;
case 27:
chang_pwm(5);
break;
case 28:
chang_pwm(2);
break;
case 29:
chang_pwm(3);
break;
case 30:
chang_pwm(4);
break;
case 31:
chang_pwm(5);
break;
case 32:
chang_pwm(6);
break;
case 33:
chang_pwm(5);
break;
case 34:
chang_pwm(4);
break;
case 35:
chang_pwm(3);
break;
case 36:
chang_pwm(2);
break;
case 37:
chang_pwm(1);
break;
case 38:
chang_pwm(2);
break;
case 39:
chang_pwm(3);
break;
case 40:
chang_pwm(4);
break;
case 41:
chang_pwm(5);
break;
case 42:
chang_pwm(2);
break;
case 43:
chang_pwm(3);
break;
case 44:
sta=1;
break;
default:
break;
}
}
void CRT_PWM(void)
{
STATUSbits.PG0=1;
CTR_FLAME_Pwm();
STATUSbits.PG0=0;
if(sta_count>STA_SPEED1)
{
sta_count=0;
sta++;
}
if(udata_count>=CMR_SPEED1)
{
udata1=1;
udata_count=0;
}
}
为什么变量sta只会从1-17之间变化,超过十七就变回1,程序应该是sta=44之后才变回1才对
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
你的sta是怎么定义的
一周热门 更多>