Hi,I was working on a little electronics project: a z80 computer, while I was doing that I needed to program an EEPROM, after seeing the price of a universal programmer, I decided to make my own using an arduino.

So far I managed to read the EEPROM and to erase it using my Arduino, here you can see my code for writing 0's to the EEPROM. Now I want to burn a binary image, let's call it "data.rom", to the EEPROM. I was thinking of using serial communication and then use some sort of script that reads data.rom and that passes byte per byte to the arduino through the serial monitor. The arduino then stores the byte in "D" (see code) and then writes that byte, and then wait for a new byte and so on.

But I'm not so familiar with coding for the arduino, neither with serial communication, so I was hoping someone could help me.

// The pins that are used for the address busint AP[13] = {24,26,30,32,36,38,42,44,48,50,47,51,53};// Used by the code to decode an addressint AD[16] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};// The pins used for the Data busint DP[8] = {23,25,29,31,35,37,41,43};// Used by the code to decode a byteint DD[8] = {0,0,0,0,0,0,0,0};

// Pins used for the control busint CE = 6;int OE = 4;int WE = 2;

int i; // Used by for-loopsint A; // Used to store the current address in the main loopint D; // Used to store the byte that will be written in that cycle to address A

D = Serial.read() - '0'; // "-0" to convert ASSCI to the actual dataBut for some reason the program does this:-It asks my data, I pass it for example 0-It stores that data at the current address A-But then it also stores 0xDD and 0xDA at addresses (A+1) and (A+2)

After a bit of think I realized what was wrong: The serial monitor first sends D, but I also passed "\n" and '\r' so it passes that too, So if anyone else has this problem, in the serial monitor there's a small box saying something like also send newline and carriage return set that to no newline.

Thanks for all the help, but I still got 1 question: Is it possible to write some sort of program that sends the data that it reads from some file through the serial port so that I don't have to type all the data in the serial monitor because that could save me a lot of time.

Is it possible to write some sort of program that sends the data that it reads from some file through the serial port so that I don't have to type all the data in the serial monitor because that could save me a lot of time.

Of course it is. What OS are you using? What language(s) are you familiar with? Depending on OS and language, this ranges from nearly trivial (C# on Win7 could be used (by me, anyway) to create such a program in under an hour) to challenging.

I'm using windows 7 64 bit and I'm familiar with C, but I don't know anything about sending data through a serial port... I can make a program that reads a file and all, but how do I send a byte over a serial port in C? I'm using Codeblocks with MinGW compiler

public: //Initialize Serial communication with the given COM port Serial(char *portName); //Close the connection //NOTA: for some reason you can't connect again before exiting //the program and running it again ~Serial(); //Read data in a buffer, if nbChar is greater than the //maximum number of bytes available, it will return only the //bytes available. The function return -1 when nothing could //be read, the number of bytes actually read. int ReadData(char *buffer, unsigned int nbChar); //Writes data from a buffer through the Serial connection //return true on success. bool WriteData(char *buffer, unsigned int nbChar); //Check if we are actually connected bool IsConnected();

//Try to get the current if (!GetCommState(this->hSerial, &dcbSerialParams)) { //If impossible, show an error printf("failed to get current serial parameters!"); } else { //Define serial connection parameters for the arduino board dcbSerialParams.BaudRate=CBR_9600; dcbSerialParams.ByteSize=8; dcbSerialParams.StopBits=ONESTOPBIT; dcbSerialParams.Parity=NOPARITY;

//Use the ClearCommError function to get status info on the Serial port ClearCommError(this->hSerial, &this->errors, &this->status);

//Check if there is something to read if(this->status.cbInQue>0) { //If there is we check if there is enough data to read the required number //of characters, if not we'll read only the available characters to prevent //locking of the application. if(this->status.cbInQue>nbChar) { toRead = nbChar; } else { toRead = this->status.cbInQue; }

//Try to read the require number of chars, and return the number of read bytes on success if(ReadFile(this->hSerial, buffer, toRead, &bytesRead, NULL) && bytesRead != 0) { return bytesRead; }

}

//If nothing has been read, or that an error was detected return -1 return -1;

Can you post the final Arduino code too?Can tell what EEPROM's you can write and how you connected them?

I used an Atmel AT28C64, but using a datasheet you should be able to modify the code to make it work with any other parallel EEPROM. The connections are pretty simple just check my code, one important detail: I added a pull-up resistor to WE because when the Arduino resets the i/O pins go to a high impedance state and the WE pin will pick up noise and you might end up using data loss (Not sure if this explanation is correct, but adding a pull up resistor somehow fixed the weird data corruption when resetting the arduino). For the rest it is just direcly connecting the pins of the EEPROM to the arduino pins(check my code)

Here's the full read and write code, but before you use it, download a datasheet and try it out yourself, you'll learn a lot and it'll give you a feeling of accomplishment.

void loop() { while (Serial.available()==0) delay(1); Serial.print(Serial.read()); digitalWrite(STS, HIGH); // set the LED on delay(500); // wait for a second digitalWrite(STS, LOW); // set the LED off delay(500); // wait for a second}

I'm planning to use Dave's (Legendmythe) sketch. He used a Linux script to send the hex file over serial. I want to use Max MSP, since it can read hex files and send them over serial very easily. However I'm not sure about the speed. There a module in Max which acts as a metronome (called 'metro'). The bytes are sent every time metro sends a trigger signal. The time is specified in milliseconds. How many bytes can I send per second?