EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

PIC EEPROM EEIF flag polarity

Started by Unknown July 7, 2006
Just wondering if someone could suggest a workaround for this snippet
of pseudo code:

if ( eeif == 1 ) {
    eeif = 0
    // write eeprom
}

This piece of code (written in assembly) goes into the main loop of my
program and allows the main loop to continue executing while the EEPROM
takes its leisurely 8ms to write.

The problem is that on power-up eeif == 0, and this code can never
execute because eeif is only asserted at the end of a write.  The only
time writing can take place is via this code.

I thought about doing a dummy write on initialization as a brute force
solution to assert eeif but it seems to me a waste of an eeprom cell.

chinsta00@hotmail.com wrote:
> > if ( eeif == 1 ) { > eeif = 0 > // write eeprom > } > [snip] > The problem is that on power-up eeif == 0, and this code can never > execute because eeif is only asserted at the end of a write. The only > time writing can take place is via this code. > > I thought about doing a dummy write on initialization as a brute force > solution to assert eeif but it seems to me a waste of an eeprom cell. >
Hi, Instead of doing a dummy write you could simply set EEIF in software. This flag is writeable. hth, -- Andrzej Ekiert http://www.ekiert.com/
chinsta00@hotmail.com wrote:
> Just wondering if someone could suggest a workaround for this snippet > of pseudo code: > > if ( eeif == 1 ) { > eeif = 0 > // write eeprom > } > > This piece of code (written in assembly) goes into the main loop of my > program and allows the main loop to continue executing while the EEPROM > takes its leisurely 8ms to write.
Why not just check WR ? eg: if (WR==1) { DoWhateverIsNeededWhileEepromBusy(); }
I didn't realise WR was readable!  The datasheet only says you can set
it (cleared by hardware)  and made no mention of reading the status.
I'll give it a go!

Rocky wrote:
> > Why not just check WR ? > > eg: > if (WR==1) > { > DoWhateverIsNeededWhileEepromBusy(); > }
Why don't they mention this stuff in the data sheet?  All it says is
that EEIF is set by hardware.  Didn't realise you could *also* set it
in software!

Andrzej Ekiert wrote:
> > Hi, > Instead of doing a dummy write you could simply set EEIF in software. > This flag is writeable. > hth, > -- > Andrzej Ekiert > http://www.ekiert.com/
On 2006-07-08, chinsta00@hotmail.com <chinsta00@hotmail.com> wrote:
> Why don't they mention this stuff in the data sheet? All it says is > that EEIF is set by hardware.
They do. The section documenting each SFR has an "R" and/or a "W" above each bit indicating whether it can be read or written, along with its default value. -- John W. Temples, III

The 2024 Embedded Online Conference