Go Down

Topic: problems with parallel eeprom [solved] (Read 996 times) previous topic - next topic

legoaceking

May 12, 2014, 11:44 pm Last Edit: May 13, 2014, 06:02 pm by legoaceking Reason: 1
Recently i have been working on a small Z80 computer for a summer project.
And everything is working great... except the eeprom, i have been using a arduino mega to try to program a 28c256. (http://www.atmel.com/Images/doc0006.pdf)
The program starts by writing 0x76 to the first three lines of the eeprom, but after programing it apears that no data have been written. Anyone have any ideas? And no a off the shelf eeprom programer is not an option.

Code: [Select]
int WE = 12;
int OE = 11;
int led = 13;



void setup() {
 pinMode(WE, OUTPUT);
 pinMode(OE, OUTPUT);
 
 digitalWrite(WE, HIGH);
 digitalWrite(OE, HIGH);
 
 pinMode(26, OUTPUT);
 pinMode(27, OUTPUT);
 pinMode(28, OUTPUT);
 pinMode(29, OUTPUT);
 pinMode(30, OUTPUT);
 pinMode(31, OUTPUT);
 pinMode(32, OUTPUT);
 pinMode(33, OUTPUT);
 
 pinMode(2, OUTPUT);
 pinMode(3, OUTPUT);
 pinMode(4, OUTPUT);
 pinMode(5, OUTPUT);
 pinMode(6, OUTPUT);
 pinMode(7, OUTPUT);
 pinMode(8, OUTPUT);
 pinMode(9, OUTPUT);
 
 
 pinMode(led, OUTPUT);  
 ProgramRam(0,118,4);
 ProgramRam(1,118,4);
 ProgramRam(2,118,4);
 
 digitalWrite(OE, LOW);
 
 
 digitalWrite(26, LOW);
 digitalWrite(27, LOW);
 digitalWrite(28, LOW);
 digitalWrite(29, LOW);
 digitalWrite(30, LOW);
 digitalWrite(31, LOW);
 digitalWrite(32, LOW);
 digitalWrite(33, LOW);
 
}










void ProgramRam(int ADD, int DATA, int WAIT)
{
 digitalWrite(WE, HIGH);
 digitalWrite(26, ADD & B10000000);  digitalWrite(27, ADD & B01000000);  digitalWrite(28, ADD & B00100000);  digitalWrite(29, ADD & B00010000);
 digitalWrite(30, ADD & B00001000);  digitalWrite(31, ADD & B00000100);  digitalWrite(32, ADD & B00000010);  digitalWrite(33, ADD & B00000001);
 delay(WAIT);
 digitalWrite(WE, LOW);
 delay(WAIT);
 digitalWrite(2, DATA & B10000000);  digitalWrite(3, DATA & B01000000);  digitalWrite(4, DATA & B00100000);  digitalWrite(5, DATA & B00010000);
 digitalWrite(6, DATA & B00001000);  digitalWrite(7, DATA & B00000100);  digitalWrite(8, DATA & B00000010);  digitalWrite(9, DATA & B00000001);
 delay(WAIT);
 digitalWrite(WE, HIGH);
 delay(WAIT);
}





void loop() {
 
 digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
 delay(1000);               // wait for a second
 digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
 delay(1000);  
 
 
}


Pin 2-9 attach to D0-D7.
Pin 26-33 attach to A0-A7.
Pin 12 attaches to WE.
Pin 11 attaches to OE.
CE is attaches to GND

Thanks in advance for any help!

johnwasser

You are connecting to only 8 of the 15 address pins?  What do you do with the others?  Could someone have turned on Software Data Protection?
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

legoaceking


You are connecting to only 8 of the 15 address pins?  What do you do with the others?  Could someone have turned on Software Data Protection?



Oh i forgot to specify that...
A8-A14 are gounded.
and no SDP is not enabled.

johnwasser

Could there be some timing constraint that you are not meeting?  I would use Direct Port Manipulation:  http://www.arduino.cc/en/Reference/PortManipulation  This will allow you to set 8 output pins in one instruction  For example PORTA covers pins 22 through 29 and PORTF covers 54 through 61.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

el_supremo

You aren't controlling OE, CE and WE as shown in the AC Write waveforms diagrams on page 8 of the datasheet. Even the CE pin has to be toggled but you've got it grounded.

Pete

Don't send me technical questions via Private Message.

legoaceking

#5
May 13, 2014, 06:00 pm Last Edit: May 13, 2014, 09:15 pm by legoaceking Reason: 1
Oh hey i got it working!
After using Direct Port Manipulation and correcting the the Write waveform to the one specified on page 8 of the datasheet it works!

Heres my working code.
Code: [Select]
int led = 13;
int WE = 12;
int OE = 11;
int CE = 10;


void setup() {
 pinMode(WE, OUTPUT);
 pinMode(OE, OUTPUT);
 pinMode(CE, OUTPUT);
 digitalWrite(WE, HIGH);
 digitalWrite(CE, HIGH);
 digitalWrite(OE, LOW);
 
 pinMode(26, OUTPUT);
 pinMode(27, OUTPUT);
 pinMode(28, OUTPUT);
 pinMode(29, OUTPUT);
 pinMode(30, OUTPUT);
 pinMode(31, OUTPUT);
 pinMode(32, OUTPUT);
 pinMode(33, OUTPUT);
 
 DDRC = B11111111;  //Port C is for D0-D7
 DDRD = B11111111;  //Port D is for A0-A7
 
 pinMode(led, OUTPUT);  
 ProgramRam(0,118,52);
 ProgramRam(1,118,52);
 ProgramRam(2,118,52);
 
 PORTC = B00000000;
 PORTD = B00000000;
 
}

void ProgramRam(int ADD, int DATA, int WAIT)
{
 digitalWrite(OE, HIGH);
 digitalWrite(CE, LOW);
 delayMicroseconds(5);
 PORTD = ADD;
 delayMicroseconds(WAIT);
 digitalWrite(WE, LOW);
 delayMicroseconds(WAIT);
 PORTC = DATA;
 delayMicroseconds(WAIT);
 digitalWrite(WE, HIGH);
 digitalWrite(CE, HIGH);
 digitalWrite(OE, LOW);
 delayMicroseconds(WAIT);
 
}


void loop() {
 
 digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
 delay(1000);               // wait for a second
 digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
 delay(1000);  
}


Thanks guys!


EDIT: After i i managed to write to one of the chips i tried to write to one that seemed to be a bad chip, after messing around with it i noticed that Software Data Protection Was on, after disabling it i can write to it like normal!
So it appears that jameco sent me a chip with Software Data Protection enabled, so watch out!

EDIT 2: Heres the improved code that can use A0-A14.

Code: [Select]
int led = 13;
int WE = 12;
int OE = 11;
int CE = 10;


void setup() {
  pinMode(WE, OUTPUT);
  pinMode(OE, OUTPUT);
  pinMode(CE, OUTPUT);
  digitalWrite(WE, HIGH);
  digitalWrite(CE, HIGH);
  digitalWrite(OE, LOW);
 
  pinMode(26, OUTPUT);
  pinMode(27, OUTPUT);
  pinMode(28, OUTPUT);
  pinMode(29, OUTPUT);
  pinMode(30, OUTPUT);
  pinMode(31, OUTPUT);
  pinMode(32, OUTPUT);
  pinMode(33, OUTPUT);
 
  DDRC = B11111111;  //Port C is for D0-D7
  DDRD = B11111111;  //Port D is for A0-A7
  DDRA = B11111111;  //Port D is for A8-A14
   
  pinMode(led, OUTPUT); 
  digitalWrite(OE, HIGH);
  ProgramEEPROM(0xFF,0xFF,0xFF,51); // Heres the command that writes a byte of code.
                                    // to use it rewrite the data in to the varables.
                                    // for example if i want to write 36 to address 5544 it will look like this
                                    // ProgramEEPROM(0x36,0x55,0x44,51);    NOTE all vars are in hexadecimal.
                                    // the last var is the wait in nanosecond, this can be changed if you are useing a diffrent chip.
                                   

 
  PORTC = B00000000;
  PORTD = B00000000;
  PORTA = B00000000;
 
}

void ProgramEEPROM(int ADDUP, int ADDDOWN, int DATA, int WAIT)
{
  delayMicroseconds(5);
  PORTD = ADDDOWN;
  PORTA = ADDUP;
  delayMicroseconds(WAIT);
  digitalWrite(CE, LOW);
  digitalWrite(WE, LOW);
  delayMicroseconds(WAIT);
  PORTC = DATA;
  delayMicroseconds(WAIT);
  digitalWrite(WE, HIGH);
  digitalWrite(CE, HIGH);
  delayMicroseconds(WAIT);
 
}




void loop() {
 
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);   
}


And heres the code to disable SDP

Code: [Select]
int led = 13;
int WE = 12;
int OE = 11;
int CE = 10;


void setup() {
  pinMode(WE, OUTPUT);
  pinMode(OE, OUTPUT);
  pinMode(CE, OUTPUT);
  digitalWrite(WE, HIGH);
  digitalWrite(CE, HIGH);
  digitalWrite(OE, LOW);
 
  pinMode(26, OUTPUT);
  pinMode(27, OUTPUT);
  pinMode(28, OUTPUT);
  pinMode(29, OUTPUT);
  pinMode(30, OUTPUT);
  pinMode(31, OUTPUT);
  pinMode(32, OUTPUT);
  pinMode(33, OUTPUT);
 
  DDRC = B11111111;  //Port C is for D0-D7
  DDRD = B11111111;  //Port D is for A0-A7
  DDRA = B11111111;  //Port D is for A8-A14
   
  pinMode(led, OUTPUT); 
  digitalWrite(OE, HIGH);
  ProgramEEPROM(0x55,0x55,0xAA,51);
  ProgramEEPROM(0x2A,0xAA,0x55,51);
  ProgramEEPROM(0x55,0x55,0x80,51);
  ProgramEEPROM(0x55,0x55,0xAA,51);
  ProgramEEPROM(0x55,0x2A,0xAA,51);
  ProgramEEPROM(0x55,0x55,0x20,51);
  ProgramEEPROM(0x0A,0x0A,0xA1,51);
  ProgramEEPROM(0x0A,0x0A,0xA1,51);
 
  PORTC = B00000000;
  PORTD = B00000000;
  PORTA = B00000000;
 
}

void ProgramEEPROM(int ADDUP, int ADDDOWN, int DATA, int WAIT)
{
  delayMicroseconds(5);
  PORTD = ADDDOWN;
  PORTA = ADDUP;
  delayMicroseconds(WAIT);
  digitalWrite(CE, LOW);
  digitalWrite(WE, LOW);
  delayMicroseconds(WAIT);
  PORTC = DATA;
  delayMicroseconds(WAIT);
  digitalWrite(WE, HIGH);
  digitalWrite(CE, HIGH);
  delayMicroseconds(WAIT);
 
}

void loop() {
 
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);   
}

Go Up