0xjoey / arduino_93c46 Goto Github PK
View Code? Open in Web Editor NEWA simple library to interface an arduino with a 93C46 EEPROM chip
License: GNU General Public License v3.0
A simple library to interface an arduino with a 93C46 EEPROM chip
License: GNU General Public License v3.0
There is a serious bug in your code. For reading 16bit organization structure you assume there are 8 bits used for opcode + address together. This is incorrect, there are 2 bits of opcode and 8 bits of address (10 total). First bit of address is ignored by the chip but it still needs to be sent, the ignored bit is marked "X" in the documentation.
This error exists in other (all?) functions too.
Can you please update your Database?!
i found the Issues #4, it's open and already one year old!
I Update my 96C43.cpp and now are my Read_Datas complete different.
But your Datas are over 2 years old!!!
And can you please check you examples for Issues #3?
Is this really a wrong output, ore a half size output?
Sorry but your answers are not good documented or explained.
I become on all this changes, different outputs.
Which ones are the right ones?
Which is the right way?
What is written correctly?
Need Help!!!!!!!!!!!!
I am trying to write data to an eeprom with some success but not quite. The chip is a 93c46 128 words at 8 bit or 64 words at 16 bit. The data to go in is in 64 word (16 bit) format as follows:
data to go in
When i write it to the chip and read it back i get:
So its like its only writing one half of the value into each word.
I am using the code as below, with the data converted from hex to string to match the input type of the example code.
#include <93C46.h>
/*
* Example Sketch demonstration on how to write to (and read from) a 93C46 eeprom
*
* Wiring:
* Pin 7(CS) to Chip pin 1
* Pin 9(CS) to Chip pin 2
* Pin 10(DI/MOSI) to Chip pin 3
* Pin 11(DO/MISO) to Chip pin 4
*
* (For some chips:) GND/VCC to Chip pin 6
* This determines the organization:
* HIGH is 64x16 (Use EEPROM_MODE_16BIT)
* LOW is 128x8 (Use EEPROM_MODE_8BIT)
*
*/
#define pCS 10
#define pSK 13
#define pDI 11
#define pDO 12
// Prints all words of the buffer
void debugPrint(word* buff, int len) {
Serial.print("\n\t00\t01\t02\t03\t04\t05\t06\t07\t08\t09\t0A\t0B\t0C\t0D\t0E\t0F");
for(int i = 0; i < len; i++) {
if(i % 16 == 0) {
Serial.println();
Serial.print(i, HEX);
}
Serial.print("\t");
if(buff[i] < 0x10) {
Serial.print("0");
}
Serial.print(buff[i], HEX);
}
}
void setup() {
bool longMode = EEPROM_93C46_MODE_16BIT;
eeprom_93C46 e = eeprom_93C46(pCS, pSK, pDI, pDO);
e.set_mode(longMode);
Serial.begin(9600);
Serial.println("Writing data...");
// First, enable EW (Erase/Write)
e.ew_enable();
String writeBuffer;
if(longMode) {
writeBuffer = "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ£çô3Ø¡²¥";
//writeBuffer = (!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!,!, ,ÿÿ,ÿÿ,ÿÿ,ÿÿ,ÿÿ,ÿÿ,ÿÿ,£,,ç,ô3,Ø¡,²,¥);
} else {
writeBuffer = "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ÿÿÿÿÿÿÿÿÿÿÿÿÿÿ£çô3Ø¡²¥";
}
int len = longMode ? 64 : 128;
// Write your data
for(int i = 0; i < len; i++) {
e.write(i, writeBuffer[i]);
}
// Optionally, disable EW after writing
e.ew_disable();
Serial.println("Reading data...\n");
word readBuffer[len];
for(int i = 0; i < len; i++) {
word r = e.read(i);
readBuffer[i] = r;
Serial.print(char(r));
}
debugPrint(readBuffer, len);
Serial.println();
}
void loop() {}
Please go easy on me, this is my first interaction with Github. I'm learning to access the 93C46 eeprom embedded in a Datakey serial memory key. These operate in 16x64 bit mode. I've installed this library and I'm playing about with the example read sketch. But I dont understand. In 16x64 mode, it only reads the first 64 bytes of the buffer. Surely, it should read 128 bytes? The data is arranged in 64 "doublewords" (an old IBM assembler term there), but this is still 128 bytes (or words) of data to read. My understanding from the chips datasheet is that the only difference between 128x8 and 64x16 is the size of then control messages in and out. The actual storage is still the same - 1024 bits.
Hello.
I think that:
void eeprom_93C46::ew_enable() {
digitalWrite(_pCS, HIGH);
send_bits(HIGH, 1);
if(_mode) {
send_bits(EW_ENABLE, 8);
} else {
send_bits(EW_ENABLE<<1, 9);
}
digitalWrite(_pCS, LOW);
_ew = true;
};
void eeprom_93C46::ew_disable() {
digitalWrite(_pCS, HIGH);
send_bits(HIGH, 1);
if(_mode) {
send_bits(EW_DISABLE, 8);
} else {
send_bits(EW_DISABLE<<1, 9);
}
digitalWrite(_pCS, LOW);
_ew = false;
}
void eeprom_93C46::erase_all() {
if(!this->is_ew_enabled()) {
return;
}
digitalWrite(_pCS, HIGH);
send_bits(HIGH, 1);
if(_mode) {
send_bits(ERASE_ALL, 8);
} else {
send_bits(ERASE_ALL<<1, 9);
}
digitalWrite(_pCS, LOW);
wait();
}
void eeprom_93C46::write_all(word value) {
if(!this->is_ew_enabled()) {
return;
}
digitalWrite(_pCS, HIGH);
send_bits(HIGH, 1);
if(_mode) {
send_bits(WRITE_ALL, 8);
send_bits(0xFFFF & value, 16);
} else {
send_bits(WRITE_ALL<<1, 9);
send_bits(0xFF & value, 8);
}
digitalWrite(_pCS, LOW);
wait();
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.