问题描述
是否有任何PIC单片机的程序员在这里?
我正在学习用PICKIT2和附带的16F690芯片的一些PIC单片机编程。我通过目前试行的各种设施的工作。我可以成功地阅读从code中的EEPROM,如果我设置MPLAB EEPROM中vaklue,但我似乎不能够修改使用PIC itsself值的字节。简单地什么也没发生,我不读回修改的值,我总是得到这意味着我原来那个写不工作?
这是我的code该节,我失去的东西吗?我知道我在做了很多不必要的银行开关,我加入他们大多以确保正对错误的银行是不是问题。
; -------------------------------------------------- ----
;现在设置的EEPROM存储单元零至0×08
; -------------------------------------------------- ---- BANKSEL EEADR
CLRF EEADR;设置EE地址为零 BANKSEL EEDAT
MOVLW 0x08的;存储值0x08的EEPROM中
MOVWF EEDAT BANKSEL EECON1
BSF EECON1,雷恩;使能写入EEPROM BANKSEL EECON2
MOVLW将0x55;做的事,我们不得不这样做
MOVWF EECON2;这写可以工作
MOVLW和0xAA
MOVWF EECON2 BANKSEL EECON1
BSF EECON1,WR;最后进行写入等待
BTFSC EECON1,WR;等待写入完成
GOTO WAIT BANKSEL PORTC;只是为了确保我们在右岸
在,它详细介绍写入EEPROM的正确方法:
I noticed that you are specifically missing this line:
BCF EECON1, EEPGD ;Point to DATA memory
If EEPGD
is always set, then you'll try to write to program memory (aka overwrite the flash program memory) which should always fail unless you've gone out of your way to specifically enable that.
Aside from that, as far as I can tell from reading your code, everything else looks fine. It's okay that you're polling EECON1.WR
instead of setting an interrupt. It will cost you more power than putting the device to sleep, but of course you should just worry about one thing at a time.
这篇关于写入EEPROM的PIC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!