本帖最后由 andy2003hu 于 2012-8-30 13:11 编辑
各位大虾好,我用的是LM4F230H5QR这个片子,用到内部EEPROM用来存放用户设置的数据,现在碰到问题,在重复开机多次的情况下,EEPROM数据会丢失.工作电压为3V
我附上主函数这部分源程序:
我把程序中很多子函数都屏蔽掉,只用了显示和按键检测跟读写EEPROM的子函数,然后就频繁的开关机.目的就是验证到底是函数调用的部分影响到了EEPROM还是EEPROM本身的问题.现在情况是,在不确定的是次数时候EEPROM会丢失.
//****************************************************************************
//Main Routing
//
//*****************************************************************************
int main(void)
{
Various_Init();
if(REVISION_IS_A2)
{
SysCtlLDOSet(SYSCTL_LDO_2_75V);
}
SysCtlClockSet(SYSCTL_SYSDIV_3| SYSCTL_USE_PLL | SYSCTL_OSC_MAIN |
SYSCTL_XTAL_8MHZ);
Led_Init(); //LED4 LED0(x) LED1 LED2 LED3
Uart_Init();
SysCtlPeripheralEnable(SYSCTL_PERIPH_EEPROM0);
EEPROMInit();
Key_Init();
Learnned_Flags_Init(); //read the learnned flags
Nos_Cnt_Start();
Beep_Init();
Pressure_Set_Init(); //read the setting data from EEPROM
// Pressure_Measure_Init();
Pressure_Unit_Init(); //read the unit for pressure from EEPROM
ID_Init(); //read the learned ID
// Temperature_Measure_Init();
Temperature_Unit_Init(); //read the unit for temperature from EEPROM
// Get_NOS_Leaking_Alarm();
// Get_Other_Alarm();
Kitronix320x240x16_SSD2119Init();
GrContextInit(&sContext,&g_sKitronix320x240x16_SSD2119);
Clean_Screen_With_Nothing();
GrContextFontSet(&sContext, &g_sFontCmss20b); //设置字体
GrContextForegroundSet(&sContext,ClrWhite);
Timer_Init(50000,60000); //50000 //50MHZ frequency,per instruction time 0.02us so,50000x0.02=1ms
TimerEnable(TIMER0_BASE,TIMER_A); //LED4显示定时器在工作
//////////////////////////////////////////////////////////////////
//// Power_On_Display_Tesee(); //power on display icon
//// Delay_10ms(1000);
// Clean_Screen_With_Nothing();
// GrImageDraw(&sContext,g_pucCar,POS_CAR_X,POS_CAR_Y); //display car icon
// Power_On_Display_Frame();
// PWM_Init(); //LED2显示PWM在工作
while(1)
{
////Pressure_Unit_Init();
////Temperature_Unit_Init();
if(bfrs_main_flag==0)
{
Clean_Screen_With_Nothing();
GrImageDraw(&sContext,g_pucCar,POS_CAR_X,POS_CAR_Y); //display car icon
Power_On_Display_Frame();
Data2Disbuf();
Display_Disbuf();
GrFlush(&sContext);
bfrs_main_flag=1;
}
EEPROMRead(read,0x33,0x08);
write_temp=read[0];
LongNumber2String(disbuf,write_temp);
GrStringDraw(&sContext,disbuf,100,1,120,0);
write_temp=read[1];
LongNumber2String(disbuf,write_temp);
GrStringDraw(&sContext,disbuf,100,1,140,0);
////Pressure_Set_Init();
Key_Scan();
////ID_Init();
////Receive_Data();
GrContextFontSet(&sContext, &g_sFontCmss20b); //设置字体
GrStringDraw(&sContext,RxBuf,30,0,130,0);
if(g_uckeyvalue==OK)
{
EEPROMProgram(write,0x33,0x08);
write[0]=0x01;
EEPROMProgram(write,EE_ADD_FLAG_UNIT_PRESSURE,0x04);
g_uckeyvalue=0;
}
if(g_uckeyvalue==SET)
{
ucloop_m_flag=1;
ucfrs_m_enter=0;
}
if(g_uckeyvalue==UP)
{
g_uckeyvalue=0;
uctemp_m_UL++;
ulpressure_m_UL++;
}
if(g_uckeyvalue==DOWN)
{
g_uckeyvalue=0;
uctemp_m_UL--;
ulpressure_m_UL--;
}
//// Manue_Routing();
//// Alarm_Routing();
if((bflag_ul_nos==1)||(bflag_ul_nos==1)||(bflag_ul_nos==1)||(bflag_ul_nos==1)||(bflag_ul_nos==1))
{
UARTPutString("NOS WARNING!!!",UART1_BASE);
UARTCharPut(UART1_BASE,'\n');
}
}
} |