Searching \ for '[PIC]: EEPROM write woes' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/memory.htm?key=eeprom
Search entire site for: 'EEPROM write woes'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: EEPROM write woes'
2002\06\07@005141 by Pic Dude

flavicon
face
This is why I'm bald... been ripping my hair out trying
to figure out this problem.  At first, I was not waiting
for EEIF to be set and noticed that data was not getting
written to the EEPROM.  Then, I added the 3 lines to wait
on EEIF set and get an odd result -- when the routine
gets called, it works some times and other times it hangs
-- the code just freezes.  (No WDT btw).

I've checked (prior to waiting on EEIF) with the simulator
and it works there.  Also verified that it's getting the
right values for the data and location.  The way I see it,
no matter what is passed in, this routine should work,
right?  It should not hang.  And most of the routine is
from the datasheet.

I do have TMR0 interrupts occuring, but that should not
hang this routine, should it?  Yes, I do save and restore
W & STATUS in the ISR.

Anyone have clues as to what may be happening?

Cheers,
-Neil.


       ;------------------------------------------------------
       ; Write data (in EEPARAM) to EEPROM location (in W)
       ;------------------------------------------------------
SetEEData:
       bsf     STATUS,RP1      ; Bank 2
       bcf     STATUS,RP0      ; Bank 2

       movwf   EEADR
       movf    EEPARAM,W       ; Data to be stored
       movwf   EEDATA
       bsf     STATUS,RP0      ; Bank 3
       bcf     EECON1,EEPGD    ; Point to data memory
       bsf     EECON1,WREN     ; Enable writes
       bcf     INTCON,GIE      ; Disable interrupts (if enabled)
       movlw   H'55'           ; Special seq
       movwf   EECON2          ; ...
       movlw   H'AA'           ; ...
       movwf   EECON2          ; ...
       bsf     EECON1,WR       ; Start write operation
       bsf     INTCON,GIE      ; Enable interrupts (only if being used)
       bcf     EECON1,WREN     ; Disable writes

       bcf     STATUS,RP1      ; Reset to bank 0
       bcf     STATUS,RP0      ;

WaitEEWriteComplete:
       btfss   PIR2,EEIF
       goto    WaitEEWriteComplete

       return

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2002\06\07@012740 by David Duffy

flavicon
face
part 1 810 bytes content-type:text/plain; x-avg-checked=avg-ok-44DF5450; charset=us-ascii; format=flowed (unknown type 8bit not decoded)

At 11:29 PM 06/06/2002 -0500, you wrote:
>This is why I'm bald... been ripping my hair out trying
>to figure out this problem.  At first, I was not waiting
>for EEIF to be set and noticed that data was not getting
>written to the EEPROM.  Then, I added the 3 lines to wait
>on EEIF set and get an odd result -- when the routine
>gets called, it works some times and other times it hangs
>-- the code just freezes.  (No WDT btw).

Hi Neil,
Which PIC is this code for ?
Regards...

___________________________________________
David Duffy        Audio Visual Devices P/L
U8, 9-11 Trade St, Cleveland 4163 Australia
Ph: +61 7 38210362   Fax: +61 7 38210281
New Web: http://www.audiovisualdevices.com.au
___________________________________________


part 2 144 bytes
--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2002\06\07@014835 by Jinx

face picon face
>
> WaitEEWriteComplete:
>         btfss   PIR2,EEIF
>         goto    WaitEEWriteComplete

You should add

          bcf      PIR2,EEIF

to clear EEIF. See if that makes a difference - there may
be something in your program that's reacting to EEIF being
set outside of the EEPROM routine. The rest of the code
looks alright

>         return

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2002\06\07@014931 by Tony Nixon

flavicon
picon face
Pic Dude wrote:


>
> WaitEEWriteComplete:
>         btfss   PIR2,EEIF
>         goto    WaitEEWriteComplete
>
>         return

Shouldn't you clear the EEIF bit after it is set by hardware ready for
the next write.


--
Best regards

Tony

mICros
http://www.bubblesoftonline.com
spam_OUTsalesTakeThisOuTspambubblesoftonline.com

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2002\06\07@020123 by Pic Dude

flavicon
face
Oops -- 16F872.



-----Original Message-----
From: pic microcontroller discussion list
[.....PICLISTKILLspamspam@spam@MITVMA.MIT.EDU]On Behalf Of David Duffy
Sent: Friday, June 07, 2002 12:15 AM
To: PICLISTspamKILLspamMITVMA.MIT.EDU
Subject: Re: [PIC]: EEPROM write woes


At 11:29 PM 06/06/2002 -0500, you wrote:
>This is why I'm bald... been ripping my hair out trying
>to figure out this problem.  At first, I was not waiting
>for EEIF to be set and noticed that data was not getting
>written to the EEPROM.  Then, I added the 3 lines to wait
>on EEIF set and get an odd result -- when the routine
>gets called, it works some times and other times it hangs
>-- the code just freezes.  (No WDT btw).

Hi Neil,
Which PIC is this code for ?
Regards...

___________________________________________
David Duffy        Audio Visual Devices P/L
U8, 9-11 Trade St, Cleveland 4163 Australia
Ph: +61 7 38210362   Fax: +61 7 38210281
New Web: http://www.audiovisualdevices.com.au
___________________________________________

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2002\06\07@020424 by Pic Dude

flavicon
face
You may be onto something there ... since posting
the email, I've been trying to find a sequence of
steps to reproduce the problem and noticed that it
will write the EEPROM once, but not after that.

Also, I'm writing hours to EEPROM and then minutes
to EEPROM, and noticed that if I swap the order of
these, I get different results.

This could explain the symptoms I'm seeing.  I'll
be back...

Thanks,
-Neil.



{Original Message removed}

2002\06\07@021050 by Pic Dude

flavicon
face
Testing this now.  Stay tuned....
-Neil.




-----Original Message-----
From: pic microcontroller discussion list
[.....PICLISTKILLspamspam.....MITVMA.MIT.EDU]On Behalf Of Tony Nixon
Sent: Friday, June 07, 2002 12:15 AM
To: EraseMEPICLISTspam_OUTspamTakeThisOuTMITVMA.MIT.EDU
Subject: Re: [PIC]: EEPROM write woes


Pic Dude wrote:


>
> WaitEEWriteComplete:
>         btfss   PIR2,EEIF
>         goto    WaitEEWriteComplete
>
>         return

Shouldn't you clear the EEIF bit after it is set by hardware ready for
the next write.


--
Best regards

Tony

mICros
http://www.bubblesoftonline.com
salesspamspam_OUTbubblesoftonline.com

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2002\06\07@022821 by Pic Dude

flavicon
face
Bingo!  Thanks Tony & Jinx.  Ideally, I'd think it
would be better to clear the EEIF at the start of the
write routine (seems more logical), but that would
involve switching to bank 0 first.  And it still
works this way.

I believe Tony is in Aus, but are you in that corner
of the planet Jinx?  Or are you in the US like I am
and just have no life?  :-)

Cheers,
-Neil.




{Original Message removed}

2002\06\07@024910 by Jinx

face picon face
> Bingo!  Thanks Tony & Jinx.

Li'l PIC monkeys'll get you any way they can eh ?

I shouldn't have been such a shrinking violet about it
after you'd said you have timer IRQs happening. Your
ISR routine for those is obviously picking up the EEIF
and going off into parts unknown. Where you clear EEIF
is up to you, as long as you avoid the problem you
just had. It wouldn't be a bad idea to keep the bcf inside
the EE routine. If you can't predict when the timer IRQ
will come then you should bcf as soon as you don't need
the EEIF anymore

> I believe Tony is in Aus,

Tony also believes he's in Australia

> but are you in that corner of the planet Jinx?  Or are
> you in the US like I am and just have no life?  :-)

Lifeless in New Zealand (just across the Sydney Harbour Bridge)

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2002\06\07@030653 by Mircea Chiriciuc

flavicon
face
EEPARAM is in bank2?
You don't have to enable interrupts since the interrupts flags are set
regardless of the interrupt state (on/off).
BTW what PIC are we talking about?

MIRCEA CHIRICIUC
EMCO INVEST

{Original Message removed}

2002\06\07@074324 by Olin Lathrop

face picon face
>         ;------------------------------------------------------
>         ; Write data (in EEPARAM) to EEPROM location (in W)
>         ;------------------------------------------------------
> SetEEData:
>         bsf     STATUS,RP1      ; Bank 2
>         bcf     STATUS,RP0      ; Bank 2

Check out my DBANKIF and related macros in STD.INS.ASPIC at
http://www.embedinc.com/pic/.  What you are doing may be correct in this
instance (I didn't check), but is a bug waiting to happen if you get the
desired bank wrong.  Let the assembler figure this out.

>         movwf   EEADR
>         movf    EEPARAM,W       ; Data to be stored
>         movwf   EEDATA

You should be checking that the previous write completed by waiting for the
WR bit in EECON1 to be 0.  This could well be your problem.

The relevant section in the manual is only 3/4 of a page.  For the 16F87x
see section 4.3 "Writing to the EEPROM Data Memory" on page 43 of DS3029C.

{Quote hidden}

*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2002\06\16@190246 by Tony Nixon

flavicon
picon face
Jinx wrote:
>
> > I believe Tony is in Aus,
>
> Tony also believes he's in Australia

I was the last time I looked :-)

--
Best regards

Tony

mICros
http://www.bubblesoftonline.com
@spam@salesKILLspamspambubblesoftonline.com

--
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 2002 , 2003 only
- Today
- New search...