gnupic: PIC16F628
Subject:
PIC16F628
From:
Stefano ####@####.####
Date:
10 Nov 2001 19:33:36 -0000
Message-Id: <Pine.LNX.4.21.0111101429380.10070-100000@nietzsche.mit.edu>
I found that the PIC16F628 has the same problem when writing and reading
EECON1,WR.
I found a workaround for the F874 and F877 and I assume that the harware
EEPROM core is similar with the F627/F628 processors.
Please read the F874/7 erratas and apply to the F628 too.
The result is simply adding a couple of nops jafter the EEPROM write
instruction:
before:
.....
movlw 0xAA ;
movwf EECON2 ; write AAh
bsf EECON1,WR ; set WE bit enable write, start writing
EEWRcon btfsc EECON1,WR ; wait until WRITE is over
goto EEWRcon ; wait until WRITE is over
bcf EECON1,WREN ; disable write EEPROM capability
bcf STATUS,RP0 ; bank0
bcf STATUS,RP1 ; bank0
return ;
after:
.....
movlw 0xAA ;
movwf EECON2 ; write AAh
bsf EECON1,WR ; set WE bit enable write, start writing
nop ; DO NOT REMOVE ; STEFANO workaround for 16F628
nop ; DO NOT REMOVE ; STEFANO workaround for 16F628
EEWRcon btfsc EECON1,WR ; wait until WRITE is over
goto EEWRcon ; wait until WRITE is over
bcf EECON1,WREN ; disable write EEPROM capability
bcf STATUS,RP0 ; bank0
bcf STATUS,RP1 ; bank0
return ;
I have the feeling that the F628 at 20MHZ need more then 2 nops !!
Stefano