Programming CAT28C65 - Page 1
Forum section: electronics / beginners

author: koba30
author_rank: Contributor
timestamp: June 15, 2018, 11:04:57 pm
content: HiI am programming a EEPROM with a Arduino Mega, i have two EEPROM types, ATMEL AT28C64B, that works fine, reading and programming works, but the other one a CAT28C65BP only is possible reading, i check the programming software proteccion on the two types, on the ATMEL i can activate and desactivate the software proteccion.Code://Lectura//mostrando los datos de cada direccion por medio del leds//Definimos puerto de direcciones#define A0 2#define A1 3#define A2 4#define A3 5#define A4 6#define A5 7#define A6 8#define A7 9#define A8 10#define A9 11#define A10 12#define A11 32#define A12 33#define A13 34#define A14 35#define A15 36#define W_enable 38#define ReadWrite 39#define Out_enable 40#define Chip_enable 41//Definimos puerto de datos#define D0 22#define D1 23#define D2 24#define D3 25#define D4 26#define D5 27#define D6 28#define D7 29long addr=0;byte datosmem=0;int contador=0;int datos=0;/////////////////////////////////////////////////////////void SetAddress(long a){digitalWrite(A0, (a&1)?HIGH:LOW );digitalWrite(A1, (a&2)?HIGH:LOW );digitalWrite(A2, (a&4)?HIGH:LOW );digitalWrite(A3, (a&8)?HIGH:LOW );digitalWrite(A4, (a&16)?HIGH:LOW );digitalWrite(A5, (a&32)?HIGH:LOW );digitalWrite(A6, (a&64)?HIGH:LOW );digitalWrite(A7, (a&128)?HIGH:LOW );digitalWrite(A8, (a&256)?HIGH:LOW );digitalWrite(A9, (a&512)?HIGH:LOW );digitalWrite(A10, (a&1024)?HIGH:LOW );digitalWrite(A11, (a&2048)?HIGH:LOW );digitalWrite(A12, (a&4096)?HIGH:LOW );digitalWrite(A13, (a&8192)?HIGH:LOW );digitalWrite(A14, (a&16384)?HIGH:LOW );digitalWrite(A15, (a&32768)?HIGH:LOW );}/////////////////////////////////////////////////////void SetData(long a){digitalWrite(D0, (a&1)?HIGH:LOW );digitalWrite(D1, (a&2)?HIGH:LOW );digitalWrite(D2, (a&4)?HIGH:LOW );digitalWrite(D3, (a&8)?HIGH:LOW );digitalWrite(D4, (a&16)?HIGH:LOW );digitalWrite(D5, (a&32)?HIGH:LOW );digitalWrite(D6, (a&64)?HIGH:LOW );digitalWrite(D7, (a&128)?HIGH:LOW );}//Funcion para leer datosbyte ReadData(){byte b = 0;if (digitalRead(D0) == HIGH) b |= 1;if (digitalRead(D1) == HIGH) b |= 2;if (digitalRead(D2) == HIGH) b |= 4;if (digitalRead(D3) == HIGH) b |= 8;if (digitalRead(D4) == HIGH) b |= 16;if (digitalRead(D5) == HIGH) b |= 32;if (digitalRead(D6) == HIGH) b |= 64;if (digitalRead(D7) == HIGH) b |= 128;return(b);}/////////////////////////////////////////////////////////////////void setup() {// put your setup code here, to run once:Serial.begin(9600); //Inicio puerto serialpinMode(13,OUTPUT); //Configuro salidas direccionespinMode(A0,OUTPUT);pinMode(A1,OUTPUT);pinMode(A2,OUTPUT);pinMode(A3,OUTPUT);pinMode(A4,OUTPUT);pinMode(A5,OUTPUT);pinMode(A6,OUTPUT);pinMode(A7,OUTPUT);pinMode(A8,OUTPUT);pinMode(A9,OUTPUT);pinMode(A10,OUTPUT);pinMode(A11,OUTPUT);pinMode(A12,OUTPUT);pinMode(A13,OUTPUT);pinMode(A14,OUTPUT);pinMode(A15,OUTPUT);pinMode(W_enable,OUTPUT);pinMode(ReadWrite,INPUT);pinMode(Out_enable,OUTPUT);pinMode(Chip_enable,OUTPUT);delay(50);/////////////////////////////////////////////////////}/////////////////////////////////////////////////////////////////void loop() {// put your main code here, to run repeatedly:if (digitalRead (ReadWrite)==0){ //Cero para leer//Configuro entradas pines de datospinMode(D0,INPUT);pinMode(D1,INPUT);pinMode(D2,INPUT);pinMode(D3,INPUT);pinMode(D4,INPUT);pinMode(D5,INPUT);pinMode(D6,INPUT);pinMode(D7,INPUT);digitalWrite(W_enable,HIGH);digitalWrite(Chip_enable,HIGH);digitalWrite(Out_enable, HIGH);Serial.print("0\t1\t2\t3\t4\t5\t6\t7\tAddress");Serial.println(" ");while(addr<32) //Lee hasta la posicion anterior{ //a la direccion puestaSetAddress(addr);delay(1);digitalWrite(Chip_enable,LOW);delayMicroseconds(10);digitalWrite(Out_enable,LOW);delay(1);datosmem=ReadData();digitalWrite(Out_enable,HIGH);digitalWrite(Chip_enable,HIGH);Serial.print(datosmem);Serial.print("\t");addr=addr+1;contador=contador+1;if(contador==8){Serial.println(addr);contador=0;}}}else { //Si ReadWrite es 1 ejecuto codigo abajo////////////////////////////////////////////////////////////////////////\/////////////////// ESCRITURA/////////////////////////////////////////////Configuro entradas pines de datospinMode(D0,OUTPUT);pinMode(D1,OUTPUT);pinMode(D2,OUTPUT);pinMode(D3,OUTPUT);pinMode(D4,OUTPUT);pinMode(D5,OUTPUT);pinMode(D6,OUTPUT);pinMode(D7,OUTPUT);digitalWrite(Out_enable,HIGH); // High:pines datos ENTRADA / Low:pines datos SALIDAdigitalWrite(W_enable,HIGH);digitalWrite(Chip_enable,HIGH);Serial.print("0\t1\t2\t3\t4\t5\t6\t7\tAddress");Serial.println(" ");while(addr<32) //Lee hasta la posicion anterior{ //a la direccion puesta///////////////////////////////////////////////////////////*SetAddress(5461);SetData(170);digitalWrite(Chip_enable,LOW);delayMicroseconds(10);digitalWrite(W_enable,LOW);delay(5);digitalWrite(W_enable,HIGH);digitalWrite(Chip_enable,HIGH);delay(5);SetAddress(2730);SetData(85);digitalWrite(Chip_enable,LOW);delayMicroseconds(10);digitalWrite(W_enable,LOW);delay(5);digitalWrite(W_enable,HIGH);digitalWrite(Chip_enable,HIGH);delay(5);SetAddress(5461);SetData(160);digitalWrite(Chip_enable,LOW);delayMicroseconds(10);digitalWrite(W_enable,LOW);delay(5);digitalWrite(W_enable,HIGH);digitalWrite(Chip_enable,HIGH);delay(5);*/////////////////////////////////////////////////////////SetAddress(addr);SetData(datos);//datos=datos+1;digitalWrite(Chip_enable,LOW);delayMicroseconds(10);digitalWrite(W_enable,LOW);delay(5);digitalWrite(W_enable,HIGH);digitalWrite(Chip_enable,HIGH);delay(5);Serial.print(datos);Serial.print("\t");addr=addr+1;contador=contador+1;if(contador==8){Serial.println(addr);contador=0;}}}while(true)digitalWrite(13,HIGH);digitalWrite(Chip_enable,HIGH);digitalWrite(Out_enable,HIGH);}Can anybody helpme to know what is happening to fail the programming on the CAT28C65.Thanks in advance.