Searching \ for '[PIC]: EEPROM problem with writes' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page:
Search entire site for: 'EEPROM problem with writes'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: EEPROM problem with writes'
2001\01\26@115536 by Justin Richards

Greetings All,

I have tried to implement EEPROM writes on 16F84 at 3.2768 Mhz using Charles Manning's Assembler, KIT 81 and PICALL. WDT disabled, Power up timer enabled. GIE and TMR0 enabled at initialization

Once the subroutine below has been called all subsequent reads to any EEPROM location returns the '9' (used as the write test data).  However, if it is put thru a power down/up cycle then subsequent reads return values as expected. ie the '9' is in the right place and everything else as it should be.

If I rem out the 6 lines as shown '*', all subsequent reads are normal.

Anyone any idea where I am going wrong.


RamToEeprom ;*************************************************
                       movlw    EEFaceTens     ;Address where data written
                       movwf    EEADR,f           ;move it to the address reg
                       movlw 9                         ;just some test data
                       movwf EEData,f              ;move it the Data reg ShiftNextRamByte                                  ;Sub will later move 5 bytes
                       bcf GIE                          ;Disable all interrupts
                       btfsc GIE                       ;was it successful
                       goto ShiftNextRamByte   ;no, try and set it again
                       bsf RP0                         ;switch to bank 1
                       bsf WREN                     ;Enable EEprom writes
                       bcf EEIF                        ;clear the write success flag
*                       movlw 55h,w                   ;55 cause manual says so
*                      movwf EECON2,f            ;write it to the control reg
*                      movlw 0AAh,w                ;AA cause manual says so
*                      movwf EECON2,f            ;write it to the control reg

                     bsf WR                           ;this initiates the write
                     bsf GIE                           ;re-enable interrupts
                     nop                                ;just in case it needs some time
*WaitForWrite   btfsc EEIF                      ;has the write finished
*                      goto WaitForWrite           ;no, then wait some more
                     bcf EEIF                         ;clear the flag                       bcf WREN                      ;clear WREN when not writing
                     bcf RP0                          ;switch back to bank 0
;RamToEeprom End Sub

-- hint: To leave the PICList

2001\01\27@005140 by Justin Richards

I have discovered the problem with my code.  I should be checking the state
of the WR bit and not the EEIF.  The manual does imply the user should set
and Int or poll the EEIF bit and doesn't make complete sense to me but it
now works.

{Original Message removed}

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