NVRAM corrupted on reset

Hello,
I'm using a 1Mbit NVRAM ZEROPOWER (http://fr.farnell.com/jsp/search/productdetail.jsp?SKU=1218170) as a ROM replacement
for a 8-bit CPU project.
I'd like to program it with my arduino mega.
For the time being, I only use the 256 first bytes of the memory (A7+ are connected to ground).
So, I have connected my arduino digital pins to A0..A7, D0..D7, Chip Enable, Output Enable and Write Enable (whatever
their name).
I have written a simple sketch, that stores X in address X, for X in 0..255. And then reads the memory, to check that the values
are ok. Then, I change the sketch to disable writing, and only read the memory and do the check part.
The problem is : after an arduino's reset, a few bytes are altered. After several resets, a lot of bytes are altered.
Sometimes, a value comes back OK after being wrong for several resets, which puzzles me... or maybe it is just a single bit that got back to its original value.
I think maybe the NVRAM inputs (the arduino's outputs) are unstable during the reset time, and so the Write pin gets enabled and the memory is written.
I've wired the Write pin to VCC : the content of memory isn't altered anymore after any RESET, so I definitely think that the
problem is here.
I'm a newbie in electronics, so I need some advice, because:

  • I'd like to be able to program this NVRAM with the arduino
  • and then, use it like a ROM/RAM for my 8-bit microprocessor
    The datasheet tells to use:
  • a 0.1 µF capa. between VCC and VSS
  • a 1N5817 diode between VCC and VSS
    I've only tested with the capa, which leads to massive data corruption. I didn't test the diode, I have to look for one.
    I've tried with a 0.1 µF cap between VCC and Write pin : it works far better, just a single byte gets corrupted
    once in a while. But it's not OK, I need it to work all the time and never get corrupted.

Any idea ?

Thanks.

Boz

So, I have connected my arduino digital pins to A0..A7, D0..D7,

Which arduino pins are you using? All of them?

You need pull-ups or pull downs in the enable lines so they dont float when your arduino is reseted.

Hum, I don't understand your question. I've connected pins A0..A7 (memory) to
digital pins 22..29 (arduino), if I remember correctly (I don't have the board in front of me),
and D0..D7 (memory) to 30..37 (arduino).

Senso:
You need pull-ups or pull downs in the enable lines so they dont float when your arduino is reseted.

Thank you for your answer. Could you tell me...

  • As the 3 enable lines are active low, I think my best shot is to use pull-ups, to set them inactive, am I correct? (I know it sounds like a silly question, but I'm really a newbie !)
  • What enable lines should I pull-up ? Chip enable only ? Write enable ? Chip enable + Write enable ? All 3 enable lines (chip/output/write) ?
  • What resistor value would you advise me to use ? It's a basic 5V set-up, with just a chip or two.

Use 3 10kOhm resistors its enougth to calm it down, and put one in each enable line, to connect them you put one end of the resistor in each enable line and the other end connects to 5v.

Senso:
Use 3 10kOhm resistors its enougth to calm it down, and put one in each enable line, to connect them you put one end of the resistor in each enable line and the other end connects to 5v.

OK, I'll test it tonite, thank you !

Boz

Senso:
Use 3 10kOhm resistors its enougth to calm it down, and put one in each enable line, to connect them you put one end of the resistor in each enable line and the other end connects to 5v.

Well... I've tried everything for several hours, and it's still not working... I'm feeling a bit lost. :0
Adding a resistor definitely drops down the amount of corrupted bytes, but some always remain...
And it doesn't matter if I pull up OR down the enable lines ! It doesn't change the amount of
corrupted bytes (I thought that pulling down the enable lines would result in a large amount of memory
corruption, but no, nada...). I've checked no voltage (0V) on the resistor with my voltmetter, during the reset phase. Is it normal ?
When I directly connect Chip enable & Write enable to GND (and disconnect them from arduino),
nearly the whole memory gets corrupted on the next reset. When I connect them to VCC, no corruption
happens at all. So I still think this is a good track to follow...
I've also tried higher resistor values (120 K) and lower (220 ohms). Nothing changes at all...
What could go wrong ?

Boz

I have one of those chips at home, I could try it.
Show me your code.

Senso:
I have one of those chips at home, I could try it.
Show me your code.

Hi, thank you, that's nice of you.
I've attached the code.
Just a short explanation of the wiring:

  • I use 11 pins from the NVRAM (A0..A10). They are connected to pins 53, 51, 49, etc, on the arduino (eg, A0 is connected to pin 53, A1 to pin 51).
  • data pins (D0..D7) are connected to pins 38,40,42, etc.
    (address & data pins are in reversed order, it was just easier to wire... the "stepa" & "stepd" vars take that into account)
  • pin 12 is for a push button, to allow to write again the nvram with correct data (ie memory = i & 0xff) if pushed within 4 seconds at start
    - pins 22, 24 & 26 are for the chip enable, output enable and write enable pins.
    BTW, my arduino is an ATMega.
    Thank you for your time again...
    Boz
    nvram.txt (3.58 KB)

Big woops, I only have an duemilanove, so I dont have enough pins to test it :confused:

Senso:
Big woops, I only have an duemilanove, so I dont have enough pins to test it :confused:

Well, you don't have to use all the address pins, as long as you ground unused ones.
In my tests, I have used pins A0 .. A10, but on some tests I used only pins A0..A3 for
example.

One thing that I notice is that you dont configure all your pins in the first lines of code, but rather set some enable lines and only then you set all the pins to the desired state.

Senso:
One thing that I notice is that you dont configure all your pins in the first lines of code, but rather set some enable lines and only then you set all the pins to the desired state.

Do you thing it could be important ? I mean, I thought the more important was to set Chip enable/Write Enable and Output Enable to HIGH asap, so as to disable chip writing.
What I'm thinking of is:

  • when the Arduino is resetting and the power is going up, is it possible that the Write pin of the memory receives a logical LO ?
    I mean, if I use a pull-up resistor on Write (to avoid RAM corruption), both signal should go up from 0V to +5V (when power rises).
    But since the Write pin is connected through the resistor, its voltage should be lower than VCC ? should it be?
    (the arduino's VCC is connected to both memory's VCC and Write Enable through resistor - as a pull-up resistor).
    Is it possible that when the VCC pin gets enough power to start to work, the Write enable is still UNDER the logical HI state ?
    I don't have an oscilloscope to check that, I've built a poor man's one, with another Arduino, but I managed to fry one of my USB ports on
    my laptop ! :~
    And it's rather slow, a few kHz if I remember well. Don't know if it's enough...

That part is not NVRAM, it is SRAM with battery backup. How good is the coin cell battery in it?

The internal coin cell will maintain data in the
M48Z128/Y/V after the initial application of VCC for
an accumulated period of at least 10 years when
VCC is less than VSO. As system power returns
and VCC rises above VSO, the battery is disconnected,
and the power supply is switched to external
VCC. Write protection continues for tER after
VCC reaches VPFD to allow for processor stabilization.
After tER, normal RAM operation can resume.
For more information on Battery Storage Life refer
to the Application Note AN1012.

Do you have the capacitor & diode connected as shown in Figure 10?

ICC transients, including those produced by output
switching, can produce voltage fluctuations, resulting
in spikes on the VCC bus. These transients
can be reduced if capacitors are used to store energy
which stabilizes the VCC bus. The energy
stored in the bypass capacitors will be released as
low going spikes are generated or energy will be
absorbed when overshoots occur. A ceramic bypass
capacitor value of 0.1?F (see Figure 10.) is
recommended in order to provide the needed filtering.
In addition to transients that are caused by normal
SRAM operation, power cycling can generate negative
voltage spikes on VCC that drive it to values
below VSS by as much as one volt. These negative
spikes can cause data corruption in the SRAM
while in battery backup mode. To protect from
these voltage spikes, ST recommends connecting
a schottky diode from VCC to VSS (cathode connected
to VCC, anode to VSS). (Schottky diode
1N5817 is recommended for through hole and
MBRS120T3 is recommended for surface-mount).