Go Down

Topic: Write protection pin on external EEPROM (Read 421 times) previous topic - next topic

tompsonneke

Oct 25, 2019, 10:59 am Last Edit: Oct 25, 2019, 11:00 am by tompsonneke
First: I'm just a beginner, so I might be asking stupid questions, but I appreciate any feedback.



For a project I'm going to use an external EEPROM. I've made a PCB and just need to order it. But before I do that, I want to make sure that it is even possible.
I've read a lot about EEPROM's and what the best practices (page 8!) are. Apparently they can be written to during start-up and powering down of the arduino, because those might make the I2C lines noisy. This could potentially corrupt data on it in the long term. I'm using the EEPROM to store some static, long term things like multiple sentences in multiple languages and also for some values that need to be able to be changed.
The solution is to use the WP (write protect) pin of the EEPROM. When this is high, the EEPROM won't write new data and just ignore requests. When low, you can write to it.
So the solution would be to pull that pin high through a pullup resistor to 5V and connecting that to a pin on the arduino. When the arduino pulls the line low, the write protect is disabled and the EEPROM can be written to. After writing, the WP pin needs to get high again to protect the data. It's that last step that I have some questions about.



Now, my problem/questions:
-I only have analog pins left. It's my understanding this doesn't really matter since you can just use them as digital outputs, right?
-My more important question: Using the arduino pin to pull it low seems to be no problem, but what when I want the write protection to be on again? Can I just toggle the pin to a digital high? Since it is already connected to the 5V power via a resistor, won't that be a problem (having 2 different 5V simultaneously connected). Or do I just set it to an input pin (and ignore the input), and if so: a digital or analog input, with internal pullup resistor or not?
Schematic




Thanks for reading and for the feedback.

Lucario448

-I only have analog pins left. It's my understanding this doesn't really matter since you can just use them as digital outputs, right?
Yes indeed. What you can't do on those is an analogWrite().


-My more important question: Using the arduino pin to pull it low seems to be no problem, but what when I want the write protection to be on again? Can I just toggle the pin to a digital high?
Correct, because the microcontroller "internally" ties the line to either VCC (aka 5V, high state, source current) or ground (aka GND, low state, sink current); but as long as the pin is set as an output, otherwise is like adding another series resistor to that "internal connection" (aka input mode, high impedance state).



Since it is already connected to the 5V power via a resistor, won't that be a problem (having 2 different 5V simultaneously connected).
The resistor is actually for when the "internal connection" ties the line to ground (low); without it at this state would be a straight short-circuit probably frying the microcontroller. That's why you'll never connect voltage directly or by a very low-valued resistor (4.7k is usually the minimum).



Or do I just set it to an input pin (and ignore the input)
I don't recommend this not because of damaging the micro, but because the high impedance state might not pull the line low properly (or even at all), and it also reduces the noise inmmunity (which beats up the purpose of a pull-up/down resistor).


and if so: a digital or analog input, with internal pullup resistor or not?
Since we are talking about binary states, digital but output (I've explained why before).

Using the built-in pull-up doesn't make any sense either; because in this case the input is on the EEPROM, not on the Arduino. The internal pull-up is only used to read state changes of an external device (e. g. pushbuttons, sensors, ICs, etc.); but in this case it's the other way around: the Arduino produces these changes that the EEPROM reads.
So, if the EEPROM's WP is already an input, then the Arduino has to be an output. Another reason why...

Go Up