我试图从PIC16F84中初始化的EEPROM中读取信息(在MPLAB中模拟),并且无法理解,为什么在调试器中我总是得到二进制'1010'(=十六进制为0x0A),但在EEPROM中有3个值。我没有正确地初始化它们或者可能以不同的顺序排列其他值? 列表p = 16F84 基数十六进制
;---------------------------------------------------------------------
RP0 equ 5
STATUS equ 0x03
EEDATA equ 0x08
EEADR equ 0x09
EECON1 equ 0x88
RD equ 0
;----------------------------------------------------------------------
counter equ 0x10
pointer equ 0x15
;----------------------------------------------------------------------
BANK0 macro
bcf STATUS, RP0
endm
BANK1 macro
bsf STATUS, RP0
endm
;----------------------------------------------------------------------
org 0x2100 ; EEPROM Data
de b'1010', b'0110', b'0001'
org 0x0000
goto start
start:
BANK0
clrw ; WREG = 0
movlw 3 ; WREG = 3
movwf counter ; counter = WREG => 3
init:
clrw ; WREG = 0
read_data:
incf pointer, 1 ; pointer += 1
movf pointer, 0 ; WREG = pointer
movfw EEADR ; get address
BANK1
bsf EECON1, RD ; read
BANK0
movf EEDATA, W ; WREG = EEDATA
goto read_data
done_loop:
goto done_loop
end
答案 0 :(得分:2)
你有两个错误!
1)在开始读取EEPROM时设置指针值,如:
movl 1
movwf pointer
2)变化:
movfw EEADR ; get address
到...
movwf EEADR ; set address