代码段:
/*------------------------------------------------
主函数
------------------------------------------------*/
main()
{
Init_IRQ();//初始化中断
ILI9325_Initial(); //初始化LCD
CLR_Screen(White); //用背景色清屏
LCD_PutString(0,0,"MODE:",White,Blue2);
LCD_PutString(0,16,"GAIN:",White,Blue2);
LCD_PutString(0,32,"LINECYC:",White,Blue2);
LCD_PutString(0,48,"RSTSTA:",White,Blue2);
LCD_PutString(0,64,"VRMS:",White,Blue2);
LCD_PutString(0,80,"IRMS:",White,Blue2);
LCD_PutString(0,96,"TEMP:",White,Blue2);
LCD_PutString(0,112,"AENERGY:",White,Blue2);
LCD_PutString(0,128,"PERIOD:",White,Blue2);
LCD_PutString(0,144,"count:",White,Blue2);
LCD_PutString(0,160,"sample:",White,Blue2);
ADE7753_Init();
//软件重启
ADE7753_Write(MODE,MODE_SWRST);
//18us 后执行
//增加延时18us
delayms(1);
//校正初始化
Calibration_whlsb();
//模式读取
result=ADE7753_Read(MODE);
_ltoa(result,data_buffer,16);
LCD_PutString(64,0,data_buffer,White,Blue2);
//增益
result=ADE7753_Read(GAIN);
_ltoa(result,data_2,16);
LCD_PutString(64,16,data_2,White,Blue2);
result=ADE7753_Read(PERIOD);
_ltoa(result,data_buffer,16);
LCD_PutString(64,128,data_buffer,White,Blue2);
while(1)
{
LED_1=~LED_1;
if(FLAG==1)
{
//关中断
EA=0;
FLAG=0;
//读取状态寄存器
result=ADE7753_Read(RSTSTATUS);
_ltoa(result,data_buffer,16);
LCD_PutString(64,48,data_buffer,White,Blue2);
if(result&IRQE_ZX)
{
LED=~LED;
//读取电流值
IRMS_result=ADE7753_Read(IRMS);
TempIRMS = (TempIRMS*7+IRMS_result)>>3;
IRMS_result= TempIRMS;
_ltoa(IRMS_result,IRMS_buffer,16);
LCD_PutString(64,80,IRMS_buffer,White,Blue2);
//读取电压值
VRMS_result=ADE7753_Read(VRMS);
TempVRMS=(TempVRMS*7+VRMS_result)>>3;
VRMS_result=TempVRMS;
_ltoa(VRMS_result,VRMS_buffer,16);
LCD_PutString(64,64,VRMS_buffer,White,Blue2);
_ltoa(count,data_buffer,16);
LCD_PutString(64,144,data_buffer,White,Blue2);
count++;
}
//开中断
EA=1;
}
}
}
其中,读取电流的代码没显示在LCD上,而下面的读取电流显示在LCD上,这是为什么??难道KEIL在编译时优化了,该怎么改呢?求大神指导 |