Hi,
I would like to assemble a 29LV640 memory programmer, tsop48, I found the tsop48 adapter for DIP, but they are 64Mbits, it is a parallel bus. So I think it will be more appropriate to use the data bus via SPI to store the file, that is, an SD card.
(I thought about making a graphical interface for the computer and using the serial port, but I believe it would be slower. According to calculations, using 8MB and 115200bps would give about 9.26 min, In addition, the SD card interface is now ready for use)
https://www.calctool.org/CALC/prof/computing/transfer_time
I modified a sample SD card reading and writing example, to write and read an 8MB (64Mbits) file, the times are as follows:
- Write: 296s (4,93 min)
- Read: 78s (1,3 min)
It seems acceptable to me this time for data storage, not counting the access time of the 29LV640 memory.
I thought about the DUE arduino, for its performance, also for having 3V3 input and output pins.
Any tips to improve performance, in addition to directly manipulating the input and output pins?
/*
SD card read/write
This example shows how to read and write data to and from an SD card file
The circuit:
SD card attached to SPI bus as follows:
** UNO: MOSI - pin 11, MISO - pin 12, CLK - pin 13, CS - pin 4 (CS pin can be changed)
and pin #10 (SS) must be an output
** Mega: MOSI - pin 51, MISO - pin 50, CLK - pin 52, CS - pin 4 (CS pin can be changed)
and pin #52 (SS) must be an output
** Leonardo: Connect to hardware SPI via the ICSP header
created Nov 2010 by David A. Mellis
modified 9 Apr 2012 by Tom Igoe
This example code is in the public domain.
*/
#include <SPI.h>
#include <SD.h>
File myFile;
// change this to match your SD shield or module;
// Arduino Ethernet shield: pin 4
// Adafruit SD shields and modules: pin 10
// Sparkfun SD shield: pin 8
const int chipSelect = 6;
uint32_t millis1 = 0;
uint32_t millis2 = 0;
uint32_t millis3 = 0;
uint32_t byte_cnt = 0;
void setup()
{
pinMode(13, OUTPUT);
// Open serial communications and wait for port to open:
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.print("Initializing SD card...");
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
// Note that even if it's not used as the CS pin, the hardware SS pin
// (10 on most Arduino boards, 53 on the Mega) must be left as an output
// or the SD library functions will not work.
pinMode(SS, OUTPUT);
if (!SD.begin(chipSelect)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
myFile = SD.open("test.txt", FILE_WRITE);
Serial.println("FILE_WRITE");
// bytes: 8388608
// if the file opened okay, write to it:
if (myFile) {
millis1 = millis();
//Serial.print("Writing to test.txt...");
//myFile.println("testing 1, 2, 3.");
for (uint32_t i = 0; i < 8388608; i++) {
myFile.write(255);
byte_cnt++;
if ((millis3 + 500) < millis()) {
millis3 = millis();
digitalWrite(13, !digitalRead(13));
Serial.print("byte cnt: ");
Serial.println(byte_cnt, DEC);
}
}
millis2 = millis();
Serial.print("write time (sec.): ");
Serial.println((millis2 - millis1) / 1000, DEC);
// close the file:
myFile.close();
Serial.println("done.");
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
Serial.println("FILE_READ");
byte_cnt = 0;
// re-open the file for reading:
myFile = SD.open("file.bin");
if (myFile) {
Serial.println("file.bin:");
millis1 = millis();
// read from the file until there's nothing else in it:
while (myFile.available()) {
//Serial.write(myFile.read());
myFile.read();
byte_cnt++;
if ((millis3 + 500) < millis()) {
millis3 = millis();
digitalWrite(13, !digitalRead(13));
Serial.print("byte cnt: ");
Serial.println(byte_cnt, DEC);
}
}
millis2 = millis();
Serial.print("read time (sec.): ");
Serial.println((millis2 - millis1) / 1000, DEC);
// close the file:
myFile.close();
} else {
// if the file didn't open, print an error:
Serial.println("error opening file.bin");
}
}
void loop()
{
// nothing happens after setup
}