help: PIC16F628 and EEPROM

Hello guys, I'm desperately trying to write and read on the EEPROM of the PIC16F628 without any success ;-(( I use the following code : W_EEPROM MOVF ADRESSE,0 MOVWF EEADR MOVF VALEEPROM,0 MOVWF EEDATA BSF STATUS, RP0 BSF EECON1, WREN MOVLW H'55' MOVWF EECON2 MOVLW H'AA' MOVWF EECON2 BSF EECON1,WR BCF STATUS, RP0 RETURN

R_EEPROM MOVF ADRESSE,0 MOVWF EEADR BSF STATUS,RP0 BSF EECON1,RD BCF STATUS,RP0 MOVF EEDATA,0 MOVWF VALEEPROM RETURN

ADRESSE is the the data address where the VALEEPROM value should be stored . I tried the the adresses H'05' and H'06'

I tried it on a PIC16F84 and it worksIs the code wrong? How can I verify that the writing is correct? Can someone send a example wich I can use Thanks in advance for your help, Georges.

snipped-for-privacy@hotmail.com

Reply to
Georges Konstantinidis
Loading thread data ...

You need to get the 16F62X datasheet errata from Microchip's website. That should show you the fix and get you aware of other problems.

Reply to
Gary Kato

Hallo Gary Kato !:

The 16F628 and 16F628A works fine (no problems with the eeprom). The 16F648A is rubbish !!!

You MUST detaily read the EEPROM-RW-Conditions. F.E. you must disable the interrupts for initialise of the r/w sequence.

From the Datesheet :

And don't forgot a while wait ..... (4-8 milliseconds) ;-) !

--
Grzegorz Zalot

complex ltd.
office tel/fax : +48 32 2505840
mobil : +48 501 301515

http://www.complex.org.pl/
mailto:complex@alpha.pl
Reply to
Grzegorz Zalot

When should I wait? "Grzegorz Zalot" a écrit dans le message de news: snipped-for-privacy@alpha.pl...

That

16F648A is
Reply to
Georges Konstantinidis

I tried with the errata... But...Actually I need to store 2 values. When I store the value at the address H'02' , the value at the address H'06' is also changed when I read it????? I used the serial port to send commands to store the values

"Grzegorz Zalot" a écrit dans le message de news: snipped-for-privacy@alpha.pl...

That

16F648A is
Reply to
Georges Konstantinidis

Georges, I found that changing the EEADR register in any way while a write was taking place would currupt the write.

I use the following BEFORE reads and writes

R_EEPROM btfsc EECON1,WR goto R_EEPROM

W_EEPROM btfsc EECON1,WR goto W_EEPROM

It allows the write to happen while other code is executing (maybe NOT a good idea on the F648...)

Good Luck

Robert

Reply to
Robert Gush

Hallo Georges Konstantinidis !:

For test use please the programmer (f.e. Picstart). I think, the error is probabily in your Serial port procedure .....

GZ.

Reply to
Grzegorz Zalot

Since you say that it works with one PIC and not the other, I have seen this problem. I don't have a manual in front of me, but there is a bit in EECON1 that needs to be cleared. I forgot the name of the bit, but a '1' writes to flash, and a '0' writes to EEPROM.

Many times people can do eeprom operations without any problems because the power-up values "usually" default to 0. However, on some parts, this particular bit is an unknown power-up value. So for 70% of the chips of one particular family, you might not have problems, but the other 30% will initialize this bit to a '1', and you'll think the chip is no good.

Try looking at the EECON1 register description. I think it is bit 6, and look at that bit's description to see if that is the one that selects the flash bank or the eeprom bank, and set it to a '0'. See if that helps.

-Mike

Reply to
Mike V.

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.