[HELP] How to read/write an EPROM, 27C160 using Arduino Uno

Hi guys, I´m in need of some help here. I recently bought a Arduino Uno board, which I´m going to use as an EPROM programmer. (Tought it was wiser to spend US$25 on an Arduino board than with an EPROM programmer for using it just once..) I was told it was relatively easy to accomplish. But I´m stuck, since I don´t know much about these memories.

The EPROM is a M27C160, it has 42 pins, it came in a FDIP42W package. Here´s the datasheet: http://pdf.datasheetcatalog.com/datasheet/stmicroelectronics/2382.pdf The source file to be writen is a .bin on the computer.

Also, I´ll be using it in 8bit mode, to replace a 36 pins MASK ROM of the same size, and I don´t know much about how the conversion is done, I would gladly accept some help :D

Thanks a lot

I did something similar a while back, reading and writing to a 6264 SRAM. To do the same with that EPROM will require 5 74HC595 chips (parallel out/serial in shift registers) and 2 74HC165 (parallel in/serial out SR) chips. 3 ea, 74595 chips to send the address (20 bits), 2 more to send data to the EPROM and the 2 ea. 74165 chips to read the data from the EPROM. I used SPI to send address and send and receive data, with several digital outputs for control lines. I can post a schematic of the 6264 project if you think it may help. The 6264 has only 13 address lines and 8 data so not as complicated as your project but may give an idea.

Haven't checked, but I suspect you need a 12V or some such programming pulse on the EPROM, so will need to arrange a driver circuit for that - usually a CMOS open-collector buffer wired so that one of its gates can pull the programming pin low and the other can drive a PNP transistor on the 12V to pull the programming pin high to perform the write. These gates must be driven directly from Arduino port pins and have (2k2) pull-downs to prevent them activating spuriously.

groundfungus: I did something similar a while back, reading and writing to a 6264 SRAM. To do the same with that EPROM will require 5 74HC595 chips (parallel out/serial in shift registers) and 2 74HC165 (parallel in/serial out SR) chips. 3 ea, 74595 chips to send the address (20 bits), 2 more to send data to the EPROM and the 2 ea. 74165 chips to read the data from the EPROM. I used SPI to send address and send and receive data, with several digital outputs for control lines. I can post a schematic of the 6264 project if you think it may help. The 6264 has only 13 address lines and 8 data so not as complicated as your project but may give an idea.

Sure it would help, can you post it?

And the code. I took the loop() code out as all it did was generate values to test read and write… The reading and writing is in the functions. Sorry for the huge image, but when I tried to reduce it it lost some lines and stuff. As was pointed out, you will need to add the programming pulse control.

#include <SPI.h>

// SERIAL RAM PROJECT
// 3/10/2013
// 74595 AND 74165 SHIFT REGISTERS AND HM6264 SRAM
// in 8K chunks decoded by 74138
// SPI interface to send and receive data and address
// direct port access for speedy write (srAddEn, srDatEn, stA_D
// ramWr on port D and read (stOutData, ramOe on port B)

int srDataEn = 4;    //595 data output enable
int srAddEn = 5;      //595 address output enable
int stA_D = 6;        //595 transfer to output reg
int ramWr = 7;       //write enable to ram 
int ramOe = 8;       //ram output enable
int stOutData = 9;    //parallel load strobe to 165
int serDataIn = 11;    //MOSI serial data out to ram
int serA_DOut = 12;    // MISO serial data out of ram
int clock = 13;        //ahhhh clock  SCL
int lf = 10;
int trigVal = 10;
int currentB = 0;
int triggerB =0;
int prePoints =100;
int bufferSize = 4000;
byte val = 0;
long time = 0;
int sampleInterval = 200;


void setup() {
  Serial.begin(9600);
  SPI.begin();
  SPI.setClockDivider(SPI_CLOCK_DIV8 );  //
  SPI.setBitOrder(MSBFIRST);
  SPI.setDataMode(SPI_MODE0); 
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  pinMode(6, OUTPUT);
  pinMode(7, OUTPUT); 
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, INPUT);
  pinMode(13, OUTPUT);
  
  digitalWrite(srDataEn, HIGH); //4
  digitalWrite(srAddEn, HIGH); //5
  digitalWrite(stA_D, LOW); //6
  digitalWrite(ramWr, HIGH); //7 
  digitalWrite(clock, LOW);  //SCK 13
  digitalWrite(serA_DOut, LOW);//MOSI    
  digitalWrite(ramOe, HIGH);//8
  digitalWrite(stOutData, HIGH);//9
}

void loop() { }
  

void writeRam(int add, byte dat) {
  byte hiAdd = highByte(add);
  hiAdd = hiAdd | 0x80; //cs1 low,cs2 high
  SPI.transfer(hiAdd); 
  SPI.transfer(lowByte(add)); 
  SPI.transfer(dat);   
  PORTD =  B11110010 ;    //stA_D high to transfer address and data 
                          //to shift register output registers
  PORTD =  B10000010 ;    // stA_D low, enable shift register outputs
  PORTD =  B00000010 ;    //ramWr low to write data
  PORTD =  B10110010 ;    //return ramWr high and disable sr outputs
}

byte readRam(int add) {
  byte data = 0x33;
  byte hiAdd = highByte(add);
  hiAdd = hiAdd | 0x80; //cs1 tied low,cs2 pulse high
  SPI.transfer(hiAdd); 
  SPI.transfer(lowByte(add)); 
  SPI.transfer(data);   
  PORTD = B11110010;    //stA_D high to transfer add and data to
                        //sr output registers
  PORTD = B10010010;    //stA_D back high, enable add sr ONLY outputs
  PORTB = PORTB & B11111110;    //enable ram outputs
  PORTB = PORTB & B11111100;    //stOutData high to || load 165 with ram data
  PORTB = PORTB | B11111111;    //stOutData back high, disable ram outputs
  PORTD = B10110010;            //disable address sr outputs
  data = SPI.transfer(0x00);
  return(data); 
}

Thanks, It seemed like a lot of work :D, I´ll give it a try when I have some time.

Paul__B:
Haven’t checked, but I suspect you need a 12V or some such programming pulse on the EPROM, so will need to arrange a driver circuit for that - usually a CMOS open-collector buffer wired so that one of its gates can pull the programming pin low and the other can drive a PNP transistor on the 12V to pull the programming pin high to perform the write. These gates must be driven directly from Arduino port pins and have (2k2) pull-downs to prevent them activating spuriously.

Paul, thanks, i tought I would just set the programming pin to a 12,5v source… I´ll try to understand it better.

halls: Paul, thanks, I thought I would just set the programming pin to a 12,5v source.. I'll try to understand it better.

At the minimum, you need a switch so that the programming voltage is not present when you insert and remove the EPROM from the socket and power up the programmer.

It then depends on the programming algorithm. In older EPROMs, the programming pulse of high(er) voltage had to be carefully timed and thus strictly controlled by the hardware and software. As I say, without studying the specifications, I do not know whether later chips include internal switching of the programming voltage as do EEPROMs, in which case it would suffice for the software once running, to indicate when you need to turn on a programming switch and leave the voltage on until the entire process was complete.