Skip to content

Read and write EEPROMs using the Microwire protocol, such as the ST93C66

Notifications You must be signed in to change notification settings

5ch4um1/MicrowireEEPROM

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

forked from

Microwire EEPROM Library for Arduino

and just added 2 examples that seem to work on my box (arduino nano clone) with the eeprom i want to read. (93c66)

if you copy the dump from the arduino serial monitor and save it to a text file, you might want to remove the carriage returns and bring it into a more human readable format by adding the leading zeros:

cat tacho16bitfixed.txt | awk '{gsub("\r",""); print $6}' | awk ' {for(i=length($0);i<4;i++){$0="0"$0}print}' | xargs -n8

Original Text:

This library enables you to read and write EEPROM chips which use the Microwire protocol. Examples are chips such as the ST93C66 or 93LC46. See the datasheets of these chips for a description of the protocol.

Why not just use SPI?

For some Microwire EEPROMS you could use the Arduinos SPI interface, however, this does not work in all cases --- some chips count the number of clock pulses between the start bit and the falling edge of the clock signal. SPI works on multiples of eight bits, so if the address width does not happen to be five (quite small) or thirteen (quite large) bits, it will not work.

Therefore this library bitbangs the Microwire protocol. This also means you have complete flexibility over which Arduino pins you want to use.

Usage

The Microwire protocol uses four signals:

  • chip select
  • clock
  • data in
  • data out

When initializing this library, you need to assign pin numbers to these signals. Furthermore, EEPROMs come in different variants, i.e., sizes and how many bits are accessed per address (usually 8 or 16). You also need to set the width of the address bus, the pagesize (bits per address) and speed (clock period in microseconds).

int CS=13; int CLK=12; int DI=7; int DO=2;
int PGS=16; int ADW=8; int SPD=200;
MicrowireEEPROM ME(CS, CLK, DI, DO, PGS, ADW, SPD); 

Afterwards you can use the functions read/write/writeEnable/writeDisable as shown in the code below:

// writeEnable must be called before the first write 
ME.writeEnable();

// write a value to each address and read it back
for (int addr=0; addr < (1<<ADW); addr++) {
  int w = (42 + addr);
  ME.write(addr, w);
  int r = ME.read(addr);
}

// prevent writing by accident
ME.writeDisable();

Also see the example sketch for a complete code.

About

Read and write EEPROMs using the Microwire protocol, such as the ST93C66

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • C++ 100.0%