求大神指点!
ccs吧
全部回复
仅看楼主
level 1
dusz℃ 楼主
图片来自:HWGonly1的百度相册这个仿真图,配上这个MPLAB IDE编写的在 Proteus仿真的代码,为何会出现只能显示第一屏“Vacant Car”的问题?
是中断无效?还是电路问题?
跪求大神指点啊!!!
#include"flex_lcd.c"
int32 RunMileage=0;
int mode=0;
int1 flag=TRUE;
int32 Price_calc()
{
int32 Price; //running with this at 100*
if(RunMileage<=2300)
Price=80000;
else if((RunMileage>2300)&&(RunMileage<=35000))
Price=80000+(RunMileage-2300)*26;
else if(RunMileage>35000)
Price=111200+(RunMileage-35000)*35;
return price;
}
//No idea if this calculation is right....
void end()
{
lcd_putc('\f');
mode=0;
RunMileage=0;
}
#int_ext
void breakloop()
{
flag=1;
if (++mode==3)
mode=0; //'% division, and should be avoided in an interrupt
}
void carrying()
{
setup_timer_1(T1_EXTERNAL_SYNC | T1_DIV_BY_1);
set_timer1(0);
}
void main()
{
int16 old_timer, temp_timer;
int32 Price;
delay_ms(500);
lcd_init();
ext_int_edge(H_TO_L);
clear_interrupt(INT_EXT);
enable_interrupts(INT_EXT);
enable_interrupts(GLOBAL);
while(TRUE)
{
if (flag==TRUE)
{
//note where the flag test is...
flag=FALSE;
switch (MODE) {
case 0:
printf(lcd_putc,"\f\nVacant Car");
break;
case 1:
printf(lcd_putc,"\f\nWelcome");
delay_ms(1000);
carrying();
printf(lcd_putc,"\f\nFare");
old_timer=get_timer1();
mode=2; //automatically advance to 'running'
break;
}
}
//Now nowhere do you read the timer. Guessing this is actually
//The 'mileage'. What units though?. 1/10th mile?. 1/100th mile?.
temp_timer=get_timer1();
if (temp_timer != old_timer)
{
//timer has changed so calculate
if (mode==2)
{
lcd_gotoxy(1,1);
old_timer=temp_timer;
//assuming 'RunMileage' is the timer value
RunMileage=temp_timer;
Price=Price_calc(); //calculate price so far
Price/=100; //because I use *100 in factors
printf(lcd_putc,"%5.2Lw",Price);
}
}
}
}
2014年07月03日 11点07分 1
1