--- In , "Igor Janjatovic" <kodrat@p...> wrote: > Hello Phil, > > *DO NOT* use "bcf INTCON, GIE" do disable interrupts! > > This is how you disable interrupts on PIC MCUs: > > loop bcf INTCON, GIE > btfsc INTCON, GIE > goto loop > > For details, download and read AN576 "Techniques to Disable Global > Interrupts". Why don't the microchip datasheets use this? The 5 datasheets that I've looked at all just bcf the flag in their sample code. I understand the reasoning, though. > > You should clear WR bit *AFTER* writing to eeprom is completed (after > checking PIR1,EEIF), not before! The EEPROM write logic clears WR, not software. Do you mean WREN? I don't see any documentation where it says to wait on clearing it and the 877A datasheet, for example, says that clearing the WREN is ok after initiating a write - implying that one need not wait for completion. In the sample code sequence, it also shows clearing the WREN bit before checking for completion of the write. I think I'm gonna go with what I've got since it seems to work just fine (famous last words). > > Everything else is OK although I like placing few NOPs after "bsf EECON1, > WR" :) > > Regards, > Igor |
|
eeprom write errors?
Started by ●October 11, 2004
Reply by ●October 13, 20042004-10-13
Reply by ●October 13, 20042004-10-13
> > *DO NOT* use "bcf INTCON, GIE" do disable interrupts! > > > > This is how you disable interrupts on PIC MCUs: > > > > loop bcf INTCON, GIE > > btfsc INTCON, GIE > > goto loop > > > > For details, download and read AN576 "Techniques to Disable Global > > Interrupts". IIRC there were some PICs fore which this was required, but the modern PICs don't need it. Wouter van Ooijen -- ------- Van Ooijen Technische Informatica: www.voti.nl consultancy, development, PICmicro products docent Hogeschool van Utrecht: www.voti.nl/hvu |