Searching \ for 'Writing to 16C84 EEPROM data memory' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/memory.htm?key=data
Search entire site for: 'Writing to 16C84 EEPROM data memory'.

Truncated match.
PICList Thread
'Writing to 16C84 EEPROM data memory'
1996\07\11@181057 by leon

flavicon
picon face
Wanting to use the 16C84 EEPROM data memory, I inserted the following
code into an existing 16C84 program, which is intended to write 12H into
the first location, to try the technique out:

;PUT SOMETHING INTO EEPROM DATA MEMORY

       MOVLW   00H             ;EEPROM ADDRESS TO WRITE TO
       MOVWF   EEADR
       MOVLW   12H             ;EEPROM DATA TO PUT THERE
       MOVWF   EEDATA

;STUFF FROM PAGES 31-32 OF PIC16C84 DATA

       MOVLW   55H
       MOVWF   EECON2
       MOVLW   0AAH
       MOVWF   EECON2
       BSF     EECON1,WR       ;WR = 1
       BSF     EECON1,WREN     ;WREN = 2

After running the program, I put the chip into my programmer and read
the program and EEPROM data memory into the buffers, but the EEPROM data
has not changed. Can someone please tell me what I am doing wrong?

Leon
--
Leon Heller, G1HSM                | "Do not adjust your mind, there is
E-mail spam_OUTleonTakeThisOuTspamlfheller.demon.co.uk  |  a fault in reality": on a wall
Phone: +44 (0)1734 471424         |  many years ago in Oxford.

1996\07\11@204339 by Steve Hardy

flavicon
face
{Quote hidden}

For a start, set WREN before doing anything!
Maybe you've deleted code to save net bandwidth, but remember that
EECON1 and EECON2 are in bank 2 so you will need to change the above
to:

       MOVLW   00H             ;EEPROM ADDRESS TO WRITE TO
       MOVWF   EEADR
       MOVLW   12H             ;EEPROM DATA TO PUT THERE
       MOVWF   EEDATA

       bsf     status,RP0      ; Set bank 1

       BSF     EECON1,WREN     ; Note: this is swapped...
       MOVLW   55H
       MOVWF   EECON2
       MOVLW   0AAH
       MOVWF   EECON2
       BSF     EECON1,WR       ;   ...over from your code!

       bcf     eecon1,wren     ;Disable further writes (does not
                               ; affect current write) if necessary
       btfsc   eecon1,WR
       goto    $-1             ; Loop until write completes
       bcf     status,RP0      ; Back to bank 0, if necessary


{Quote hidden}

One must suggest more careful reading of the manual, since it's all
explained there; and excuse any errors of mine, because I don't have the
manual in front of me.


Regards,
SJH
Canberra, Australia
[who happens to be working on the exact same thing - EEPROM in the '84]

1996\07\12@145119 by leon

flavicon
picon face
In message  <.....9607120046.AA21102KILLspamspam.....keeper.stortek.com> EraseMEPICLISTspam_OUTspamTakeThisOuTMITVMA.MIT.EDU
writes:
> For a start, set WREN before doing anything!
> Maybe you've deleted code to save net bandwidth, but remember that
> EECON1 and EECON2 are in bank 2 so you will need to change the above
> to:
>
>         MOVLW   00H             ;EEPROM ADDRESS TO WRITE TO

[deleted]

Thanks very much to SJH and everyone else who assisted. That part of the
program is working fine, now.

Leon
--
Leon Heller, G1HSM                | "Do not adjust your mind, there is
E-mail leonspamspam_OUTlfheller.demon.co.uk  |  a fault in reality": on a wall
Phone: +44 (0)1734 471424         |  many years ago in Oxford.

1996\07\14@105117 by id John Philip Bodger

flavicon
face
Hi Leon, you wrote:-
>Wanting to use the 16C84 EEPROM data memory, I inserted the following
--Snip--
>After running the program, I put the chip into my programmer and read
>the program and EEPROM data memory into the buffers, but the EEPROM data
>has not changed. Can someone please tell me what I am doing wrong?
>
>Leon
>--
>Leon Heller, G1HSM                | "Do not adjust your mind, there is
>E-mail @spam@leonKILLspamspamlfheller.demon.co.uk  |  a fault in reality": on a wall
>Phone: +44 (0)1734 471424         |  many years ago in Oxford.

Here is some code taken directly from a working program I wrote. It is
written in Parallax Assembler (PASMX) but you should get the idea.
This is a clip of the list output from the assembler and the first column is
line numbers followed by the assembler code words.
You can see from this which PASMX instructions map to multiple Mchip
instructions.
In the great traddition of these things, the simpler lower level routines
are listed first. (n.b. :loop is a local label)
Sorry I didn't have time to translate it for you. I hope it is of some help.
(Contact me direct if there is anything else you need help with Leon -
remember the transputer and QL? - long time no see!)

All the best.

Dave.

 1060                                  ;Routine to write a byte to the EEPROM,
assumes EEADR and EEDATA have
 1061                                  ;already been loaded with the required
values and EEwrenable has already
 1062                                  ;been called to prime the safety
lockout mechanism.
 1063    031D- 138B                    EEwriteit       clrb    GIE
;must run with interrupts disabled
 1064    031E- 1683                                    setb    RP0
;these registers are in page 1
 1065    031F- 3055 0089                               mov     EECON2,#55h
;Required sequence to
activate write
 1066    0321- 30AA 0089                       mov     EECON2,#0AAh    ;55, AA,
set WR.
 1067    0323- 1488                                    setb    WR
 1068    0324- 1E08 2B24               :loop           jnb     EEIF,:loop
;wait until write
is complete
 1069    0326- 1108                                    clrb    WREN
;safe once again !
 1070    0327- 1208                                    clrb    EEIF
;reset indicator for next
time.
 1071    0328- 1283                                    clrb    RP0
 1072    0329- 0009                                    reti
;reenable interrupts when all done
 1073
 1074    032A- 1683                    EEread          setb    RP0
;control register is
in Page 1.
 1075    032B- 1408                                    setb    RD
;initiate read operation
 1076    032C- 1283                                    clrb    RP0
 1077    032D- 0008                                    ret
 1078
 1079    032E- 1683                    EEwrenable      setb    RP0
;EEPROM write
enable safety guard
 1080    032F- 1508                                    setb    WREN
 1081    0330- 1283                                    clrb    RP0
 1082    0331- 0008                                    ret
 1083
 1084    0332- 232E                    EEwrite         call    EEwrenable
 1085    0333- 231D                                    call    EEwriteit
 1086    0334- 0008                                    ret
 1087
 1088                                  ;Get EEPROM data into RAM
 1089                                  ;Enter with R1=source, W=destination,
R2=number of bytes to move
 1090    0335- 0084                    EEget           mov     FSR,W
;start addr of target
regs.
 1091    0336- 0826 0089               :loop           mov     EEADR,R1
;point to byte to
retrieve
 1092    0338- 232A                                    call    EEread
;select read mode
 1093    0339- 0808 0080                               mov     INDIRECT,EEDATA
;load
non-volatile value to working reg
 1094    033B- 0A84                                    inc     FSR
;next indirect address
 1095    033C- 0AA6                                    inc     R1
 1096    033D- 0BA7 2B36                       djnz    R2,:loop
 1097    033F- 0008                                    ret
 1098
 1099                                  ;Put RAM data into the EEPROM.
 1100                                  ;Enter with R1=destination, W=sorce,
R2=number of bytes to move.
 1101    0340- 0084                    EEput           mov     FSR,W
 1102    0341- 0826 0089               :loop           mov     EEADR,R1
;point to byte to store
 1103    0343- 0800 0088                               mov     EEDATA,INDIRECT
;load ram value
to EE reg
 1104    0345- 2332                                    call    EEwrite
 1105    0346- 0A84                                    inc     FSR
;next indirect sorce address
 1106    0347- 0AA6                                    inc     R1
;next destination address
 1107    0348- 0BA7 2B41                       djnz    R2,:loop
 1108    034A- 0008                                    ret

More... (looser matching)
- Last day of these posts
- In 1996 , 1997 only
- Today
- New search...