Microchip
直播中

张丽娟

7年用户 206经验值
私信 关注
[问答]

无法写入PIC12F1840数据EEProm

大家好,我用编译器函数“EEPROMYRADE”实现代码,从EEPROM和“EEPROMYWORD”中读写。读取函数正在工作,但写不起作用。我做错了什么,还是需要初始化EEPROM?下面是EEPROM读代码读取EEPROM的地址0。如果没有写入,它将给我变量中的0xFF。下面是向EEPROM写入EEPROM的代码。如果我读EEPROM内存地址,它给我0xFF,即使我的功率循环控制器也得到同样的结果。

以上来自于百度翻译


      以下为原文

    Greetings Everybody,

I have implemented code using compiler function "eeprom_read" to read from eeprom and "eeprom_write" to write. Read function is working but write is not working. Anything i am doing wrong or do i need to initialize eeprom ?

Below is the eeprom read code to read address 0 of eeprom. If it is not written it will give me 0xFF in my variable.

dp = eeprom_read(0x00);
   if(dp == 0xFF)
   {
       dp = 0;
   }

Below is the code to write to eeprom

eeprom_write(0x00, 0x01);


After writting to eeprom if i read that eeprom memory address it gives me 0xFF and even if i power cycle the controller i get the same result 0xFF

回帖(2)

王焕树

2019-1-9 15:02:00
你使用XC8吗?如果是,你可以用EEPROM限定符直接在EEPROM中声明变量。注意,你到底是如何测试这个的?请注意,每次更新固件时,它将擦除EEPROM。

以上来自于百度翻译


      以下为原文

    Are you using XC8?
If yes, you can just declare variable to be in EEPROM directly using the "eeprom" qualifier.
 
Note, how exactly are you testing this? Be aware that every time you update the firmware, it will erase the EEPROM.
举报

阎慧

2019-1-9 15:17:46
嘿,我很抱歉提出这个问题。事实上,我发现有我的编码错误。由于这个原因,控制器是无限循环的,从来没有达到。

以上来自于百度翻译


      以下为原文

    Hey,
I am extremely sorry to post the question. Actually i have found out that there was my coding fault. Due to this the controller was in infinite loop and never reached to 

eeprom_write(0x00,0x01);
举报

更多回帖

发帖
×
20
完善资料,
赚取积分