日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當(dāng)前位置:首頁 > 嵌入式 > 嵌入式職業(yè)規(guī)劃
[導(dǎo)讀]張明峰 :對現(xiàn)在有些年輕人的學(xué)習(xí)方法和效率感到悲哀!

讀寫片內(nèi)EEPROM數(shù)據(jù)區(qū),每一本相關(guān)的數(shù)據(jù)手冊都有詳細(xì)的例程,抄上去就可以了。如果連抄上也不行,那你還有什么是可以的呢?

什么都想要現(xiàn)成的,自己一點(diǎn)主觀的進(jìn)取心都沒有。你要用C寫程序,這當(dāng)然是好事,可是連現(xiàn)成的匯編語句都無法用C語言復(fù)述一遍,那你還能用C寫出什么有用的代碼?

自己如果不清楚,就不要瞎說。什么“不是將wr置1,寫完后會自動將wr置1”:事實(shí)正好相反。

可能又要說是初學(xué)之類的借口了。那反問一句:這象認(rèn)真學(xué)習(xí)的模樣嗎?

算了,附上一些代碼吧,僅供參考。

//=============================================================
//Write a byte of data into EEPROM memory
//Input:
//      eeData - data to be written
//      eeAddr - EEPROM memory address
//Return:
//      0 - successful
//      1 - data error
//      2 - time out
//=============================================================
unsigned char EE_Write(void)
{
unsigned char tmpData;

EEIF = 0;

EEDATA = eeData;   //data to write
EEADR  = eeAddr;   //adress to write
EEPGD  = 0;        //point to EE area
WREN   = 1;        //EE write enabled
GIE    = 0;        //no interrupt following
EECON2 = 0x55;     //password 55
EECON2 = 0xaa;     //password AA
WR     = 1;        //internal EE write cycle begin now
WREN   = 0;        //EE write can be disabled
GIE    = 1;        //interrupt could be enabled

timer  = 10;       //for backgound time-out control
do {
    asm("CLRWDT");
} while (EEIF==0 && timer!=0); //wait for EE write completed or time-out

if (EEIF==1 && timer!=0) {   //EE write completed normally
    tmpData = eeData;
    EE_Read();                //read back the written data
    if (tmpData == eeData)    //verify
       return(0);             //data is good
    else
       return(1);             //data is corrupted
} else
    return(2);                //WW write time out
}


//=============================================================
//Read a byte of data from EEPROM memory
//Input:
//      eeAddr - EEPROM memory address
//Output
//      eeData - data read
//=============================================================
void EE_Read(void)
{
EEDATA = 0xff;
EEADR  = eeAddr;
EEPGD  = 0;
RD     = 1;
eeData = EEDATA;
}

本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請及時(shí)聯(lián)系本站刪除( 郵箱:macysun@21ic.com )。
換一批
延伸閱讀
關(guān)閉