把数据存储于内部EEPROM中,数码管动态显示。
问题是每当数据写入内部EEPROM中时,数码管就闪烁一下!
请问大家有遇到过同样的问题吗!?大家是如何解决的呢!?
以上,谢谢。
贴上部分代码:
//---------------------------------------------------------------------------------
#include <stc89c5x.H>
#include <Intrins.H>
//---------------------------------------------------------------------------------
#define ENABLE_IAP 0x83 //<12MHz
uchar Byte_Read(uchar,uchar);
void Byte_Program(uchar,uchar,uchar);
void Sector_Erase(uchar,uchar);
void IAP_Disable();
void Trigger_IAP();
//-----------Byte_Read----------------------------
uchar Byte_Read(uchar addr1_h,uchar addr1_l)
{
uchar date;
IAP_CONTR = ENABLE_IAP ; //open IAP set Flash operation time
IAP_CMD = 0x01; //Select Read AP Mode
IAP_ADDRH = addr1_h;
IAP_ADDRL = addr1_l;
Trigger_IAP();
date =IAP_DATA;
IAP_Disable(); //关闭IAP功能,清与IAP有关的SFR
return date;
}
//------Byte_Program-------------
void Byte_Program(uchar addr2_h,uchar addr2_l,uchar date1)
{
IAP_CONTR = ENABLE_IAP ; //open IAP set Flash operation time
IAP_CMD = 0x02; // Select Read AP Mode
IAP_ADDRH = addr2_h;
IAP_ADDRL = addr2_l;
IAP_DATA = date1;
Trigger_IAP();
IAP_Disable(); //关闭IAP功能,清与IAP有关的SFR
}
//--------------Sector_Erase--------------
void Sector_Erase(uchar addr3_h,uchar addr3_l)
{
IAP_CONTR = ENABLE_IAP ; //open IAP set Flash operation time
IAP_CMD = 0x03; // Select Read AP Mode
IAP_ADDRH = addr3_h;
IAP_ADDRL = addr3_l;
Trigger_IAP();
IAP_Disable(); //关闭IAP功能,清与IAP有关的SFR
}
//--------IAP_Disable-----------
void IAP_Disable()
{
IAP_CONTR = 0;
IAP_CMD = 0;
IAP_TRIG = 0;
}
//--------Trigger IAP processing------
void Trigger_IAP()
{
uchar i;
IAP_TRIG = 0x5A;
IAP_TRIG = 0xA5;
for(i=0;i<10;i++);
}
//---------------------------------------------------------------------------------
//Name:Delay();
//Function:Software delay function
//Input:
//Output:
//---------------------------------------------------------------------------------
void Delay(uchar t) //延時程序,延時時間2ms*t
{
t_2ms=0;
while(t_2ms<t);
}
//---------------------------------------------------------------------------------
//Name:Main
//Function:
//Input:
//Output:
//---------------------------------------------------------------------------------
void Main(void)
{
//-------------------------------------------
TMOD = 0x11; //T1 setting
TL0 = INTERVAL_T0_L ; //10ms//加載定時計數值
TH0 = INTERVAL_T0_H ;
TL1 = INTERVAL_T1_L ; //2ms//加載定時計數值
TH1 = INTERVAL_T1_H ;
TR0 = ON;
TR1 = ON;
ET0 = ENABLE;
ET1 = ENABLE;
EA = ENABLE;
set_minute=Byte_Read(0x00,0x00);//讀EEPROM
set_second=Byte_Read(0x00,0x01);//讀EEPROM
second=set_second;minute=set_minute;
start_flag=0;
//=====================================================
while(1)
{
Key_scan();
Output_ctl();
}
}
//---------------------------------------------------------------------------------
//Name:Timer1
//Function:
//Input:
//Output:
//---------------------------------------------------------------------------------
void Timer1(void) interrupt 3 using 1 //2ms
{
TL1 = INTERVAL_T1_L ; //2ms
TH1 = INTERVAL_T1_H ;
t_2ms++;dis_ms++;
display();
}
//-----------------------------------------------------------------------------------------------------------
//end |
学习下