Question

Im trying to read information from initialized EEPROM in PIC16F84(which simulated in MPLAB), and can't understand, why at debugger i always get binary '1010' (=0x0A at hex), but at EEPROM have 3 values. I not correctly initialized them or maybe other values arranged in a different order? list p=16F84 radix hex

;---------------------------------------------------------------------
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
Was it helpful?

Solution

You have two mistakes!

1) Set pointer value at start reading EEPROM like:

movl    1 
movwf   pointer

2)Change:

movfw       EEADR       ; get address

to...

movwf       EEADR       ; set address
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top