Skip to content

Instantly share code, notes, and snippets.

/AT93C46D.ino Secret
Created Feb 25, 2016

Embed
What would you like to do?
//AT93C46D
#include<SPI.h>
#define DATAOUT 11//MOSI
#define DATAIN 12//MISO
#define SPICLOCK 13//sck
#define SS 10//ss
void setup()
{
pinMode(SS,OUTPUT);
pinMode(DATAOUT, OUTPUT);
pinMode(DATAIN, INPUT);
pinMode(SPICLOCK,OUTPUT);
digitalWrite(SS,LOW);
Serial.begin(9600);
SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE0));
fill();
dump();
}
void loop()
{
}
void fill()
{
Serial.println("Send EWEN opcode");
digitalWrite(SS,HIGH);
SPI.transfer(0b1001); //EWEN
SPI.transfer(0b10000000);
digitalWrite(SS,LOW);
delay(100);
for (int i=0; i < 128; i++) {
digitalWrite(SS,HIGH);
SPI.transfer(B101);
SPI.transfer(i & 0x7f);
SPI.transfer(0b00000000);
delay(10);
digitalWrite(SS,LOW);
}
delay(100);
Serial.println("Send EWDS opcode");
digitalWrite(SS,HIGH);
SPI.transfer(0b1000); //EWDS
SPI.transfer(0b00000000);
digitalWrite(SS,LOW);
delay(10);
}
void dump(){
Serial.println("Dumping AT93C46D");
byte b;
for (int i=0; i < 128; i++) {
digitalWrite(SS,HIGH);
SPI.transfer(0b11); //read opcode
SPI.transfer(i & 0x7f);
b = SPI.transfer(0); //clock data out
digitalWrite(SS,LOW);
Serial.println(b, BIN);
}
}
@mikaelpatel

This comment has been minimized.

Copy link

commented Feb 25, 2016

Line 44-45 needs fixing. See stackexchange and product spec. Too many bits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.