help: PIC16F628 and EEPROM

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
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




Re: help: PIC16F628 and EEPROM
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.

Re: help: PIC16F628 and EEPROM
Hallo Gary Kato !:
Quoted text here. Click to load it

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 :
Quoted text here. Click to load it

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

--
Grzegorz Zalot

complex ltd.
We've slightly trimmed the long signature. Click to see the full one.
Re: help: PIC16F628 and EEPROM
When should I wait?
Quoted text here. Click to load it
That
16F648A is



Re: help: PIC16F628 and EEPROM
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


Quoted text here. Click to load it
That
16F648A is



Re: help: PIC16F628 and EEPROM
Hallo Georges Konstantinidis !:
Quoted text here. Click to load it

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

GZ.


Re: help: PIC16F628 and EEPROM
Quoted text here. Click to load it


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
        <rest of code>

W_EEPROM
        btfsc  EECON1,WR
        goto   W_EEPROM
        <rest of code>

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

Good Luck

Robert

Re: help: PIC16F628 and EEPROM
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





snipped-for-privacy@suesound.co.za (Robert Gush) wrote in message
Quoted text here. Click to load it

Site Timeline