Professional Documents
Culture Documents
ROM Reader. Quick Arduino program to read a parallel-accessed ROM and dump it to
the serial
port in hex.
// How I've wired the digital pins on my Arduino to the address and data pins on
// the ROM.
static const int kPin_A0 = 53;
static const int kPin_A1 = 51;
static const int kPin_A2 = 49;
static const int kPin_A3 = 47;
static const int kPin_A4 = 45;
static const int kPin_A5 = 43;
static const int kPin_A6 = 41;
static const int kPin_A7 = 39;
static const int kPin_A8 = 46;
static const int kPin_A9 = 48;
static const int kPin_A10 = 52;
static const int kPin_A11 = 50;
static const int kPin_A12 = 37;
static const int kPin_A13 = 44;
const char hex[] = {'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
void setup()
{
// set the address lines as outputs ...
pinMode(kPin_A0, OUTPUT);
pinMode(kPin_A1, OUTPUT);
pinMode(kPin_A2, OUTPUT);
pinMode(kPin_A3, OUTPUT);
pinMode(kPin_A4, OUTPUT);
pinMode(kPin_A5, OUTPUT);
pinMode(kPin_A6, OUTPUT);
pinMode(kPin_A7, OUTPUT);
pinMode(kPin_A8, OUTPUT);
pinMode(kPin_A9, OUTPUT);
pinMode(kPin_A10, OUTPUT);
pinMode(kPin_A11, OUTPUT);
pinMode(kPin_A12, OUTPUT);
pinMode(kPin_A13, OUTPUT);
Serial.begin(9600);
}
byte ReadByte()
{
// read the current eight-bit byte being output by the ROM ...
byte b = 0;
if (digitalRead(kPin_D0)) b |= 1;
if (digitalRead(kPin_D1)) b |= 2;
if (digitalRead(kPin_D2)) b |= 4;
if (digitalRead(kPin_D3)) b |= 8;
if (digitalRead(kPin_D4)) b |= 16;
if (digitalRead(kPin_D5)) b |= 32;
if (digitalRead(kPin_D6)) b |= 64;
if (digitalRead(kPin_D7)) b |= 128;
return(b);
}
void loop()
{
byte d[16];
int x, y, addr;
Serial.print(" ");
for (y = 0; y < 16; y++)
{
char c = '.';
if (d[y] > 32 && d[y]<127) c = d[y];
Serial.print(c);
}
Serial.println("");
}