Searching \ for '[EE]: 16F876 EEPROM Problems Still' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/microchip/memory.htm?key=eeprom
Search entire site for: '16F876 EEPROM Problems Still'.

Exact match. Not showing close matches.
PICList Thread
'[EE]: 16F876 EEPROM Problems Still'
2000\12\17@210514 by David Duffy

flavicon
face
Hi All,
Last week I asked about writing more than 1 byte to the 'F876
eeprom causing me problems. I've tried polling the WR bit and
also using the write-complete interrupt with no difference. The
only way I can get the chip to program more than 1 location in
succession is to insert a small delay (12ms) after each write.
Any further ideas would be appreciated. I wrote a small routine
that writes 8-1 into eeprom locations 8-1 to prove the fault wasn't
in another area - it shows the same fault. (only writes 8th loc'n)
Below is the code I'm using for the eeprom write:

ee_write:                       ;
        bank2                   ;bank 2
        movwf   eeadr           ;set up eeprom address
        bank3                   ;bank 3
        bcf     gie             ;disable the global interrupt
        bcf     eepgd           ;make it a data eeprom write
        bsf     wren            ;enable eeprom writing
        movlw   h'55'           ;
        movwf   eecon2          ;eeprom write unlock sequence
        movlw   h'aa'           ;
        movwf   eecon2          ;eeprom write unlock sequence
        bsf     wr              ;initiate data eeprom write
        bcf     wren            ;disable the eeprom writing
        bank0                   ;bank 0
ee_wait:
        btfsc   wr            ;is the eeprom finished writing?
        goto    ee_write   ;no
        bsf     gie             ;re-enable the global interrupt
        return                  ;exit

Regards...

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu


2000\12\17@211507 by Tony Nixon

flavicon
picon face
David Duffy wrote:

>          bsf     wren            ;enable eeprom writing
>          movlw   h'55'           ;
>          movwf   eecon2          ;eeprom write unlock sequence
>          movlw   h'aa'           ;
>          movwf   eecon2          ;eeprom write unlock sequence
>          bsf     wr              ;initiate data eeprom write
>          bcf     wren            ;disable the eeprom writing


This last line probably kills the write routine.

Try leaving WR set until the write is completed.

--
Best regards

Tony

mICro's
http://www.picnpoke.com
.....salesKILLspamspam@spam@picnpoke.com

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamKILLspammitvma.mit.edu


2000\12\17@233103 by David Duffy

flavicon
face
Tony wrote:
>David Duffy wrote:
> >          bsf     wren            ;enable eeprom writing
> >          movlw   h'55'           ;
> >          movwf   eecon2          ;eeprom write unlock sequence
> >          movlw   h'aa'           ;
> >          movwf   eecon2          ;eeprom write unlock sequence
> >          bsf     wr              ;initiate data eeprom write
> >          bcf     wren            ;disable the eeprom writing
>
>
>This last line probably kills the write routine.
>
>Try leaving WR set until the write is completed.

I put the wrong version in my last email - corrected one is;

;******************************************************************************
;* 'ee_write' writes one byte.                                                *
;* enter with eeprom address in w and eeprom data in eedata (bank 2).         *
;******************************************************************************
ee_write:                       ;
        bank2                   ;bank 2
        movwf   eeadr           ;set up eeprom address
        bank0                   ;bank 0
ew_busy:                        ;
        btfsc   ee_busy         ;is the eeprom busy from a previous write?
        goto    ew_busy         ;yes, loop & wait
        bcf     gie             ;no, disable the global interupt
        bank3                   ;bank 3
        bcf     eepgd           ;make it a data eeprom write
        bsf     wren            ;enable eeprom writing
        movlw   h'55'           ;
        movwf   eecon2          ;eeprom write unlock sequence
        movlw   h'aa'           ;
        movwf   eecon2          ;eeprom write unlock sequence
        bsf     wr              ;initiate data eeprom write
        bank0                   ;bank 0
        bsf     ee_busy         ;set flag to say eeprom is busy
        bsf     gie             ;re-enable the global interupt
        return                  ;exit

If I put a 12ms delay in just before the return it works ok.
I'm now clearing the WREN bit in the interrupt routine.
My flag (ee_busy) is also cleared in the same spot.
Regards...

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam.....mitvma.mit.edu


2000\12\17@234123 by Tony Nixon

flavicon
picon face
David Duffy wrote:

> If I put a 12ms delay in just before the return it works ok.
> I'm now clearing the WREN bit in the interrupt routine.
> My flag (ee_busy) is also cleared in the same spot.
> Regards...

Have you tried simulating the code with MPASM? The EEPROM write function
is supported. That may provide a clue.

--
Best regards

Tony

mICro's
http://www.picnpoke.com
EraseMEsalesspam_OUTspamTakeThisOuTpicnpoke.com

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamspam_OUTmitvma.mit.edu


2000\12\18@145656 by rottosen

flavicon
face
David:
See my comments at ##### in the code.

Been there done EXACTLY that  :-(


David Duffy wrote:
{Quote hidden}

##### Instead put the data in a tempory location. I will call
##### it "EETemp"


> ;******************************************************************************

##### Make sure that your banks are correct. They sound wrong to me.


> ee_write:                       ;
>          bank2                   ;bank 2
>          movwf   eeadr           ;set up eeprom address

##### This store writes over the previous value that is being
##### used to write to the EEPROM if two writes are done quickly.
##### Storing the data ahead of the test for the EEPROM being
##### ready will causes the same problem.


>          bank0                   ;bank 0
> ew_busy:                        ;
>          btfsc   ee_busy         ;is the eeprom busy from a previous write?
>          goto    ew_busy         ;yes, loop & wait

##### Do the stores after the EEPROM is ready
##### Set the bank
#####      Bank2
#####      movwf   eeadr           ;set up eeprom address
##### Now Store the data
#####      movf    EETemp,W
#####      movwf   eedata


{Quote hidden}

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


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