Is there an example of how to use Arduino to program a 8 pin EEPROM chip. I would like an example with a sketch. For example, a sketch for blinking a LED, then programming that to a separate EEPROM chip. Thanks!
KeithHilton:
Is there an example of how to use Arduino to program a 8 pin EEPROM chip.
Have you tried searching on 'I2C eeprom programming'?
KeithHilton:
For example, a sketch for blinking a LED, then programming that to a separate EEPROM chip.
Are you expecting that the processor will run a sketch located in an external eeprom?
What is the type number of your 4-pin EEPROM - AT24C32, 24C64 or 24C512? Do you own a DS3231 RTC Module which holds AT24C32 EEPROM?
Do you want to store your LED blinking sketch into an external EEPROM? If so, this will be a good exercise for you and the interested Forum Members.
I'm sure there are libraries for 24-series EEPROMs; they are very simple to talk to (as in, it's so easy you can just throw it together without using a library if you want)
To read data, you write the address (1 or 2 bytes, possibly including a couple of bits of the address) to the I2C device, then request the number of bytes you want to read, and then read the values you got back with read(). I think there's a relevant limit on the amount of data you can request in one go - I think it's like 64 or 32 bytes at a time, imposed by the size of the Wire library buffer.
To write it, you just write the address as above, and then follow it with additional bytes of data to write starting from that location. Be aware that with a sequential write (writing multiple bytes at a time) you can only write within a single page (size of page is listed in datasheet) - if you write off the edge, the address counter wraps around to the start of the page.
It's about as simple as an I2C device gets.
The 25-series (the SPI ones) use a very similar protocol.
The much higher capacity SPI flash chips are more complicated to talk to.
Note about my terminology - I refer to them as 24-series and 25-series; the part numbers for these typically have 2 letters defining the company and/or product-line within the company, the number 24, and the size of the part in kbits in the name - ex, AT24C64 is a 64-kbit I2C part manufactured by atmel, 24AA512 is a 512kbit I2C part that works at 1.8~5.5v manufactured by microchip, the 25LC256 is a 256kbit SPI part manufactured by microchip that works at 2.5~5.5v (and - guess what, a 24LC256 is the same in I2C). Each company has it's own lettering, but if you look for I2C EEPROMs, if it's got 24 and a power of 2 in the name, it's virtually guaranteed to be the same thing.
It's also worth noting that there are a few chips based on newer memory tehnologies that use the same protocol, but either at a lower cost and lower rewrite limit (CBRAM), or higher cost, infinite rewrite limit, and no page boundaries (FRAM). Unfortunately you can't recognize them by the part numbers (they don't have the "24" in the name, and the numbers used by the couple of FRAM suppliers are completely different), but filtering memory chips on digikey by interface and 8-pin packages is pretty good at finding them; virtually all of the parts like this are read/written like an 24-series or 25-series.
You cannot store your sketch onto an external EEPROM*. Only data. The AVR microcontrollers used in most Arduinos are a harvard architecture - instructions can only be executed from the flash memory within the microcontroller, not external memory (short of writing a new bootloader which would read an eeprom, and copy the contents to the flash memory of the microcontroller, which seems pointless, as you'd still have the same limit of sketch size).
*well, I suppose you could store the compiled sketch to the EEPROM, but you can't run it from there, which is presumably what you want to do.
Thanks for the reply's. Yes, I am interested in transferring data from Arduino Uno to a "external eeprom". By external eeprom, I mean a 8 pin IC. IC meaning chip-integrated circuit that is not part of the Arduino Uno.
I know zero about transferring data to an external eeprom, so I don't know the numbers of any external eeprom chips. I was wanting an example sketch, and wanting the example to show how to hook up the arduino and eeprom chip.
Good to know the external eeprom does not store the sketch, only the data.
I am wanting to transfer data from the Arduino, to a 8 pin eeprom that is on a separate bread board with jumper wires. Then disconnect the Arduino from the eeprom, and power the eeprom with a battery. For example take a sketch that blinks a LED, transfer that data from a Arduino Uno to a external--"separate" 8 pin eeprom chip. Then disconnect the Arduino totally from the eeprom, and connect battery power to the eeprom. Then have the eeprom transmit the stored data, thus blinking the LED from the data stored on the eeprom. Thanks.
Also, GolamMostafa the link you posted only came up as a picture, without any sketch.
For example take a sketch that blinks a LED, transfer that data from a Arduino Uno to a external--"separate" 8 pin eeprom chip. Then disconnect the Arduino totally from the eeprom, and connect battery power to the eeprom. Then have the eeprom transmit the stored data, thus blinking the LED from the data stored on the eeprom. Thanks.
You seem to be confused between what is the "sketch" and what is "data".
An eeprom can not blink an LED. The "sketch" (i.e. program) running on the Arduino blinks the LED.
''data" typically refers to information created or retrieved by the sketch. For example, the program("sketch") reads an electronic thermometer(sensor), and the data is the temperature value returned by the sensor.
KeithHilton:
Also, GolamMostafa the link you posted only came up as a picture, without any sketch.
Let us practice the following tutorial to write a data byte (0x23) into the location 0x1234 of the AT24C512 EEPROM, read back the data, and show it on Serial Monitor.
Figure-1: Connection diagram between UNO and 24C512 EEPROM
1. Place 24C512 EEPROM on the breadboard. Make connection between the EEPROM and the UNO as per circuit diagram of Fig-1. In this system, the UNO is the master (M1) and the EEPROM is the Slave (S1). The I2C Bus address for the Slave EEPROM is 0b1010000 (0x50). We need to connect the pull-up resistors for proper operation of the I2C Bus. We wish to write 0x23 into an EEPROM location with address 0x1234.
2. Data Write Procedures:
(a) Form I2C Bus and its data transfer speed.
(b) Bring I2C Bus into START condition.
(c) Set data direction from Master to Slave (write mode).
(d) Check that the Slave is present by calling it at its address.
(e) Send the 2-byte address of the EEPROM location (upper byte first).
(f) Send the data byte for the target EEPROM location.
(g) Bring STOP condition on the I2C Bus.
(h) Insert 5 ms time delay or poll for status to detect the end-of-write cycle.
3. Data Read Procedures:
(i) Bring I2C Bus into START condition.
(j) Set data direction from Master to Slave (write mode).
(k) Check that the Slave is present by calling it at its address.
(l) Send the 2-byte address of the EEPROM location (upper byte first).
(m) Send data read request command to the Slave with number of bytes to read.
(n) Retrieve data from the buffer.
(o) Display the data on the Serial Monitor.
4. Convert the procedures of Step-3 and Step-4 into the following Programming Codes. Save the program as extEEP-1.ino.
#include <Wire.h>
#define slaveAddress 0x50
#define eepAddress 0x1234
#define databyte 0x23
void setup()
{
Serial.begin(9600);
Wire.begin(); //TWI Bus is formed at default speed
Wire.beginTransmission(slaveAddress); //
Wire.write(highByte(eepAddress)); //0x12
Wire.write(lowByte(eepAddress)); //0x34
Wire.write(databyte); //0x23
Wire.endTransmission(); //all steps: a - g done
//----check write cycle (end-of-conversion) by polling the status------ step-h.
do
{
Wire.beginTransmission(slaveAddress); //
}
while (Wire.endTransmission() != 0x00);
//---------------------------------------------------------------------
Wire.beginTransmission(slaveAddress); //Roll call; write mode
Wire.write(highByte(eepAddress)); //0x12
Wire.write(lowByte(eepAddress)); //0x34
Wire.endTransmission(); //all steps: a - g done
//---------------------------------------------------------------------
Wire.requestFrom(slaveAddress, 1); //request to slave 1-byte data to read; steps-i to m
byte x = Wire.read(); //data is read from unseen buffer into x ; step-n
//---------------------------------------------------------------------
Serial.println(x, HEX); //show data on Serial Monitor; should be 23; step-o
}
void loop()
{
}
5. Compile and upload the program of Step-4.
6. Check that the Serial Monitor shows: 23. (it shows: checked).
Thanks GolamMostafa, that was what I was looking for.
KeithHilton:
Thanks GolamMostafa, that was what I was looking for.
But what you actually asked for, seems to be more having the eeprom do the work of blinking an led after the Arduino's taken out of play, as if the eeprom has some processing ability of its own. Is that what you want to do?
...disconnect the Arduino totally from the eeprom, and connect battery power to the eeprom. Then have the eeprom transmit the stored data, thus blinking the LED from the data stored on the eeprom
Post#6 due to @cattledog has convinced the OP that the EEPROM can not execute the LED blinking program and then the Post#7 has appeared at his assistance.