Writing to EEPROM

From the user manual it sounds moderately straighforward but lacking a bit in detail. It seems you have to plonk the address ( and data if it's a write ) in the appropriate registers and tell it go do its thing.

It says it's done by using an interrupt ( and returns a byte in a register if it's a read ).

I'm not terribly keen on having to turn off other interrupts though ( which it seems to need ) . Not sure why you can't just look for an interrupt flag.

Yes, all the info's there.

Graahm

Reply to
Pooh Bear
Loading thread data ...

So, Nick, (the OP, if I read this right)

Do you understand what needs to be done ??

Donald

Reply to
Donald

Hi, Ya fairly enough. I will describe what i plan to code. In the MAIN routine i will intialise the timer0, i will use it to generate

1second.Then i will count 40 times using register r0 (167740 - 500hrs) and the other (1677) i will load in timer1 used as a counter.These values will be taken form Eeprom, by reading EEprom data. I will be holding output data high for 10seconds again using timer0. In EEprom save routine i will save the r0 and timer0,1 values. For the EEprom save routine will be started when Brown Out detect interrupt is generated.

Thanks Nick

Reply to
Nick

Hi, Details what i missed: I will be using internal EEprom - 512bytes. I will be writing to the EEprom in Byte - Byte mode. During start up in main routine i will be checking the POF power on flag. Jump to EEprom save routine will be from 002bh (Brown out Interrupt).

Thanks Nick

Reply to
Nick

Hi, Internal EEprom - 512 bytes in byte mode of LPC932. (Byte Mode: In this mode data can be read and written to one byte at a time). That is what i meant, sorry if i was not clear ienough.

Thanks, Nick

Reply to
Nick

Key questions at this point. How many bytes will you be writing?. At the moment 'brownout' is detected, how much further can the voltage drop before the processor stops working (normally if the brownout is at [say]

4.2v, and the processor is rated to run to 3v, you have something just over a volt of available drop)?. How low can you get the power consumption during this time - can you turn off all peripherals?. Given these figures, how much capacitance must be present on the supply rail to ensure that all the writes will complete before the power fails?. Remember that the code in the brownout interrupt, should, once the write is complete, sit and if the power _does not_ fail within a period of time, then check if the voltage is good (clear the interrupt flag, and test if it comes on again), return to the program.

Best Wishes

Reply to
Roger Hamlett

Hi, I will be writing 6bytes (6x4mSec.). I'll check with what you suggested. I was hoping to use 10,000 uf cap which gives me 750msec. aprox hold time(I got this somewhere from the internet). I will also check whether what you said can be done in the code. Thanks Nick

Reply to
Nick

For your info, that's not an example of serial communication. Look at a

24C02 Eeprom for an example of that.

Graham

Reply to
Pooh Bear

I'm afraid you don't get these kind of answers 'from the internet'.

The 'hold-up time' has to be *calculated* by yourself, considering the following.

  1. The 'brown-out' detect voltage.
  2. The voltage at which the uC wil fail to operate.
  3. The current drawn from the 'hold-up' cap by the uC and anything else attached to its supply. See data sheet. Affected by clock ocillator frequency for example.
  4. The hold-up capacitor value.

Graham

Reply to
Pooh Bear

(I.t)/V = C Remember that a 10000uF capacitor, will potentially introduce problems on startup, with a huge inrush current. Work out the current the circuit will draw. Take the data sheet worst case figures, and add a margin of perhaps

25% (remember that most electrolytic capacitors are +/-20%). Now you can calculate the capacitance needed, rather than relying on guesses. Realistically, it should be possible to do this with a few hundred uF, rather than tens of thousands. For instance, if the PIC cicuitry & EEPROM, with everything else disabled, draws 12mA, you need to maintain supply for 24mSec, and the brownout is 4.2v, with a 3v minimum working voltage, you get:

(0.012*24E-3)/1.2 = 240uF. Say 300uF.

Best Wishes

Reply to
Roger Hamlett

I ought to point out that the device isn't a PIC. It's an 8051 family variant.

Graham

Reply to
Pooh Bear

Sorry, I was crossing this post over, with another poster asking PIC questions. I was being quite generous on the current for a PIC, so for the

8051, should not be too far adrift.

Best Wishes

Reply to
Roger Hamlett

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.