It's going to be like a data logger but it will be 512k in size total with no formatting or spacing. I am trying to dump a few 4Mbit EPROM I found and EPROM programmer costs more than a few wires and a socket connected to my Mega so I thought I'd wire up my Mega with the EPROM and dump data to serial monitor.
No line space, no carriage return, nothing just straight 0-9 and A-Fs, just to save directly to text file to look it up and change to bin file if I need to keep it for later programming. How would I write data to the monitor that way? It's coming out with lots of spaces which makes it hard for me to read or save to text file.
No error on my IDE, just want to see how I could fix serial print formatting.
// Digital I/O pin assignments
const int romOE = 21; // ROM /output enable
const int romA0 = 30; // ROM address lines
const int romA1 = 31;
const int romA2 = 32;
const int romA3 = 33;
const int romA4 = 34;
const int romA5 = 35;
const int romA6 = 36;
const int romA7 = 37;
const int romA8 = 38;
const int romA9 = 39;
const int romA10 = 40;
const int romA11 = 41;
const int romA12 = 42;
const int romA13 = 43;
const int romA14 = 44;
const int romA15 = 45;
const int romA16 = 46;
const int romA17 = 47; // 256k
const int romA18 = 48; // 512k ROM
const int romD0 = 22; // ROM data lines
const int romD1 = 23;
const int romD2 = 24;
const int romD3 = 25;
const int romD4 = 26;
const int romD5 = 27;
const int romD6 = 28;
const int romD7 = 29;
// Global variables
unsigned long romAddr = 0L; // up to 32-bit current address
byte romData = 0; // Eight-bit ROM data
void setup()
{
Serial.begin(115200); // Enable serial output
// Set I/O initial parameters
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW); // Turn off activity indicator
pinMode(19, OUTPUT); // activity LED
pinMode(20, OUTPUT); // finished LED
digitalWrite(20, LOW);
pinMode(romOE, OUTPUT);
digitalWrite(romOE, HIGH); // Negate ROM output enable
for (int i = 0; i < 18; ++i) //address
{
pinMode(romA0 + i, OUTPUT); // Set direction of ROM address lines
}
for (int i = 0; i < 8; ++i)
{
pinMode(romD0 + i, INPUT); // Set direction of ROM data lines
}
ResetAddr(); // Set current ROM address to 0x0000
delay(8000); // Delay for time to open serial window in IDE to capture output
}
void loop()
{
digitalWrite(LED_BUILTIN, HIGH); // Turn on activity indicator
// Read ROM and send data to serial port
for (unsigned long records = 0; records < 524288; ++records)
{ // straight 512k for A0-A18,
digitalWrite(19, !digitalRead(19)); // blinky LED to show activity on D19
romData = ReadData(); // Get eight-bit data from ROM at current address
Serial.print(romData); // Print ROM data byte to serial port
IncrAddr(); // Increment ROM address lines
Serial.print(""); // Print end-of-line to serial port
}
digitalWrite(LED_BUILTIN, LOW); // Turn off activity indicator
digitalWrite(20, 0); // finished, turn on LED on D20
while (1); // Loop continuously until reset
}
void ResetAddr() // Reset ROM address bus to 0x0000
{ // runs only once at setup
romAddr = 0; // Reset address variable
for (int i = 0; i < 18; ++i) // address
{ // 19 address lines A0-A18 for 512k x 8 ROM
digitalWrite(romA0 + i, LOW); // Set all ROM address lines low
}
}
void IncrAddr() // Increment to next address
{
for (int i = 0; i < 18; ++i) // Start with A0, check each bit through whatever
{
if (bitRead(romAddr, i) == 0) // Check current bit; if zero, increment current ROM address bit
{ // and equivalent ROM address bit output, then return,
bitSet(romAddr, i); // since no carry is needed.
digitalWrite((romA0 + i), HIGH);
return;
}
bitClear(romAddr, i); // Otherwise, clear current address bit and equivalent ROM
digitalWrite((romA0 + i), LOW); // address bit output, then loop to increment
} // next higher address bit.
}
byte ReadData() // Read 8-bit ROM data at current address
{
byte result; // Eight-bit result
digitalWrite(romOE, LOW); // Assert ROM output enable
delayMicroseconds(10); // Delay to let data lines settle
result = 0; // Initialize result
for (int i = 0; i < 8; ++i)
{ // Check D0 through D7 and insert high bits into result
if (digitalRead(romD0 + i) == HIGH)
bitSet(result, i);
}
digitalWrite(romOE, HIGH); // Negate ROM output enable
return result; // Return result to caller
}