serial to eeprom - too much information :-)

I am going round in circles with all the search results and variations of the EEPROM library.

What I want to do looks dead simple.

I have 11 audio 8 bit WAV files, one is 30KB the others average 6KB, saved in a file on my PC.

I want to simply copy them onto my 24C1024 eeprom that is connected to the Arduino.

I will only need to do this once, so a seperate slow sketch would be fine.

Each file I want to later be able to call up and send to the DAC.

There is a simple looking sketch on the Wise time project, but it doesnt show any libraries, and has commands such as isWrite..

Can anyone point me in the right direction here, I am not clear about page size etc, it seems that I would like to send a batch at a time and record manually the finish address of each file, and start the next after that....?

I'm not sure what you mean by "EEPROM library." The standard EEPROM commands are for accessing the ATmega's internal EEPROM.

Have you looked at this library:
http://arduino.cc/playground/Code/I2CEEPROM24C1024

Yes thats one of the varieties I have downloaded, and the AT24C_1.2, and E24C1024.

I dont really know how to get the wav files into the arduino , I found an explanation once about how the Serial works, but I am unsure about how the serial transfer works with files of 30KB such as a wav file....

The one project I looked at had a VB program to send the files from the PC, but I couldnt run that as there was a corrupt file.......

You'll need a PC program to read the binary data of the file and transfer it over serial to the Arduino. Your code on the Arduino will need to understand the bit stream coming over serial and write that to the EEPROM.

I downloaded superterm to try and send to the arduino, but it only sees COM1 and my arduino is on com13.
Are there any better terminal programs?

For Windows I use Brey terminal, it's a good free one.

Lefty

Thanks Lefty,

thats got the TxRx leds to flicker, now I can see if I can write something to send each file to the eeprom....

If I read one byte at a time, and send it to the eeprom, until the file has all been sent, what is in the eeprom ? it started life as say "one.wav"
I am going to have to try and use part of the WaveHC library to send the file to the DAC, which is expecting a wav file.

eeprom just contains bytes - its not an SDcard with a builtin file system, just the raw memory.

But will I be able to read all those x bytes starting from address y, and feed them straight to the DAC ?

Boffin1:
But will I be able to read all those x bytes starting from address y, and feed them straight to the DAC ?

Yes, it can work just like that. However reading from an external EEPROM is somewhat slower then reading from SRAM or FLASH memory. So you should first make sure the whole I2C speed + speed of reading EEPROM will support the sample speed you require to output the music data to the DAC.

As far as storing your file data to EEPROM, it is not as simple as just dumping the 12 files of data to the EEPROM as you need to know where to save the starting address for each 'file' of data in the EEPROM. I had a similar need to store LED pattern script data to an external EEPROM. If I was just storing one pattern script then I researved the first for bytes of EEPROM (to hold a long variable) that the main sketch could read that would signify how many bytes the pattern was, starting of course at EEPROM address four as 0-3 hold the length variable. If you were going to save 11 'files' of music data then you could do something similar, the first 44 addresses of EEPROM would hold long variables that contain the EEPROM starting address for each 'file', then the first two bytes (holding a integer variable) of each 'file' would contain the length of bytes of the file. Then the main sketch would have access to all the information required to find and read out a single 'file' of data and send it to the DAC one byte at a time.

Then of course you have to write a dedicated sketch to read the music files one byte at a time from the PC and write the data to the EEPROM, making sure you don't overwrite any previously stored 'files' already loaded into the EEPROM.

So all in all, it's not as simple as one might first expect, but it can all be sorted out. Again just make sure via some calculations that you can read EEPROM data back out fast enough and send it to the DAC at the sample speed that the data requires.

That make sense?

Lefty

Thanks Lefty
I tried writing a basic sketch, reading byte by byte.
As I can't have the serial monitor to check the progress, I was going to try flashing the led while data is coming in.
I have the last address writing to the micros eeprom so that I can see where to start the next track...
I can move the start address to 44 or more to leave room for the size??

But as you say, I probably cant read fast enough to feed the DAC, I will run a read test again and see how long it takes

Heres the crude sketch I was working on :-

  #include <WProgram.h>
  #include <Wire.h>
  #include <E24C1024.h>
  #include <EEPROM.h>
  
  int inByte = 0;         // incoming serial byte
  const int ledPin =  13;      // the number of the LED pin
  int ledState = LOW;             // ledState used to set the LED
  unsigned long time;
  unsigned long finishTime;
  unsigned long errors = 0;
  unsigned long address = 0;
  byte upperbyte;   //  address is long needs to be saved in eeprom
  byte lowerbyte;   //  -"-
  
  #define MIN_ADDRESS 0  //  change to start address of each track
  #define MAX_ADDRESS 131072 // 1 device
  void setup()
  {
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
  Serial.println();
  Serial.println("E24C1024 first try");
  Serial.println();
  address = MIN_ADDRESS;
}
void loop()
{
  time = millis();
  errors = 0;
  if (Serial.available() > 0) {
    // get incoming byte:
  inByte = Serial.read();

  EEPROM1024.write(address, inByte);
  address ++;
  if (!(address % 50)) 
  {   // toggle led ?
      if (ledState == LOW){
      ledState = HIGH;
  }
  else {
        ledState = LOW;
        digitalWrite(ledPin, ledState);
      }
    }  //  end of toggle led
    if (Serial.available() <= 0) {  //  no more data coming in
      int upperbyte = highByte(address);  // to save last address                         
      int lowerbyte = lowByte(address);
      EEPROM.write(0, upperbyte) ;
      EEPROM.write(1, lowerbyte) ;
      //   finishTime = millis() - time;
    } //  end of if no more data coming in    
  } //  end of if serial available
}

OK, thanks for the tip Lefty

heres the results of reading the chip full of data, a byte at a time:-

E24C1024 Library Benchmark Sketch


Write By Byte Test:

Writing data:...........................DONE
Total Time (seconds): 722
Write operations per second: 181

Read By Byte Test:
Reading data:...........................DONE

Total Test Time (secs): 83
Read operations per second: 1579
Total errors: 0

I have got all day for the writing, but not seconds for reading !

Back to the drawing board ! The SD card setup that had been giving me trouble seems OK now, so I think I will persevere with that !