I want control 21 pins on an EEPROM without using shift registers. The pin-out diagram for the micro shows pins D0 to D23 ie 24 digital pins. If I exclude D0 and D1 this leaves me with 22, ie enough for my project. Is this correct or are there some limitations as the summary table only mentions 20 digital pins.
Which Arduino board are you using ?
Does it have analogue pins that can be used as digital pins ?
More details please, especially about the EEPROM and what you are trying to do with it
Hi, thanks
I am using a micro. I am trying to write data to a AT2864B EEPROM using addresses A0 to A10 so 11 addresses so need 21 output pins on the arduino
Why? On a Arduino Micro they have no relationship with the USB if that is a concern.
Ah you are right, so I can use them?
Can you show us a link to the pin-out you refer to?
and the table?
says
The Pro Micro is a great choice if its 18+2 pins are sufficient for your project. For more pins the Teensy is a good alternative
or
The Micro is a microcontroller board based on the ATmega32U4, developed in conjunction with Adafruit. It has 20 digital input/output pins
If you plan to deal with 11 address lines, why do you need a 21 pins for it?
8 data pins, write enable, output enable, 11 address pins. What intrigues me is the pinout shows d0 to d23 but the tech specs mention 20 digital pins
Copy and paste error? They possibly copied from the Leonardo. According to the schematic it has 24 pins.
You might have to be careful with the SS pin as it's also used to control the RX led. Test before you use it.
Thanks
You've been very helpful. Any restrictions on d14 and 15?
I am intrigued as to what you are going to do with the EEPROM and wonder whether there is an easier way to do what you want. It sounds like you are not going to have many pins left to do anything with after using so many for the EEPROM
EPROM burners often use a counter IC to handle the addressing. Then only one or two pins is needed to provide addresses, as they are accessed sequentially...
It is for an EEPROM programmer so I don't need any more pins. Thanks
Thanks. I have another version using shift registers. This is an experiment to see if I can make one without them
It's very likely, whoever was counting pins to make that documentation, excluded SDA,SCL,TX,RX. That accounts exactly for the difference between the stated 20 digital pins and the actual 24 pins.
If you have no further problem with that, please close the thread as "solved" by choosing a post as a solution.
As long as you don't intend to use them for SPI.
Be aware the D13 (IO13*) is used for the L-LED so be careful what you use it for; it might be activated during uploads or power on, no time to check that.

Thanks a lot. I wired it up using D13 to see if it works. I have written a sketch to program the EEPROM and I am getting something strange. Here is part if the sketch, just the setup part.
void setup()
{
// put your setup code here, to run once:
pinMode(WRITE_EN, OUTPUT);
digitalWrite(WRITE_EN, HIGH);
Serial.begin(57600);
while (!Serial) { delay(10); }
// Set Data pins to output
for (int n = 0; n <8; n++)
{
pinMode(datPin [n], OUTPUT);
}
//Set Address pins to output
for (int n = 0; n <11; n++)
{
pinMode(adrPin [n], OUTPUT);
}
// Program data bytes
Serial.println("Programming EEPROM");
for (int address = 0; address < 768; address += 1)
{
int flags = (address & 0b1100000000) >> 8;
int byte_sel = (address & 0b0010000000) >> 7;
int instruction = (address & 0b0001111000) >> 3;
int step = (address & 0b0000000111);
byte data = 0;
//Set address to write to
for (int n= 0; n < 11; n++)
{
digitalWrite(adrPin [n], address & 1);
address >>= 1;
}
if (byte_sel)
{
//Write byte to address //Low order bits
for (int n = 0; n <8; n += 1)
{
digitalWrite(datPin[n], data & 1);
data = data >> 1;
}
digitalWrite(WRITE_EN, LOW);
delayMicroseconds(1);
digitalWrite(WRITE_EN, HIGH);
delay(10);
} else
{
//Write byte to address //High order bits
for (int n = 0; n <8; n += 1)
{
digitalWrite(datPin[n], data >> 8 & 1);
data = data >> 1;
}
digitalWrite(WRITE_EN, LOW);
delayMicroseconds(1);
digitalWrite(WRITE_EN, HIGH);
delay(10);
}
}
// Read and print out the contents of the EEPROM
Serial.println("Reading EEPROM");
Serial.println("Z0C0 Block");
Serial.println("Read the 8 high-order bits of microcode from the first 128 bytes of EEPROM");
Begin = 0;
End = 127;
printContents();
Serial.println("Read the 8 low-order bits of microcode from the second 128 bytes of EEPROM");
Begin = 128;
End = 255;
printContents();
Serial.println("Z0C1 Block");
Serial.println("Read the 8 high-order bits of microcode from the third 128 bytes of EEPROM");
Begin = 256;
End = 383;
printContents();
Serial.println("Read the 8 low-order bits of microcode from the fourth 128 bytes of EEPROM");
Begin = 384;
End = 511;
printContents();
Serial.println("Z1C0 Block");
Serial.println("Read the 8 high-order bits of microcode from the fifth 128 bytes of EEPROM");
Begin = 512;
End = 639;
printContents();
Serial.println("Read the 8 low-order bits of microcode from the sixth 128 bytes of EEPROM");
Begin = 640;
End = 767;
printContents();
}
Printing to the monitor gives me the "Programming EEPROM" line and then nothing. If i put in some tracking print statements, I can see that the the loops are working in the programming steps as well. However the reading part does not work. Even if there is garbage written to the device, it should at least print the line "Reading EEPROM" and other Serial.println items.
Any ideas?
If you want that kind of help, you should post a schematic and some links to the device you're programming.
Hope this works.
I changed some of the sketch and now the printing to monitor works. Puzzled why. However the output is all one´s so either the read or write function does not work. Ive included the whole sketch. Thanks.
/**
* This sketch programs the microcode EEPROMs for the 8-bit breadboard computer without shift registers
*/
int adrPin [] = {13, 18, 19, 20, 21, 22, 23, 14, 12, 11, 10};
int datPin [] = {1,0,2,3,4,5,6,7};
#define WRITE_EN 8
#define OUT_EN 9
int Begin = 0;
int End = 0;
int n =0;
// Negative enabled control lines put out a 1 when disabled
// _ ______ _ ___
#define HLT 0b1101111110100111 // Halt clock
#define MICO 0b0001111110100011 // Memory address register in, Counter out
#define ROIICE 0b0100101110101111 // Ram out, Instruction in, Counter enable
#define IOMI 0b0001011110100111 // Instruction out, Memory in
#define IOAI 0b0101010110100111 // Instruction register out, A register in
#define IOJ 0b0101011110100101 // Instruction register out, Jump
#define AOOI 0b0101111010110111 // A register out, Output register in
#define ROAI 0b0100110110100111 // Ram out, A register in
#define ROBI 0b0100111110000111 // Ram out, B register in
#define AORI 0b0111111010100111 // A register out, Ram in
#define EOAIFI 0b0101110100100110 // Sum out, A register in, Flags in
#define EOAISUFI 0b0101110101100110 // Sum out, A register in, Subtract, Flags in
#define NOP 0b0101111110100111 // All controls off
int data[]=
{
MICO, ROIICE, NOP, NOP, NOP, NOP, NOP, NOP, // 0000 - NOP
MICO, ROIICE, IOMI, ROAI, NOP, NOP, NOP, NOP, // 0001 - LDA
MICO, ROIICE, IOMI, ROBI, EOAIFI, NOP, NOP, NOP, // 0010 - ADD
MICO, ROIICE, IOMI, ROBI, EOAISUFI, NOP, NOP, NOP, // 0011 - SUB
MICO, ROIICE, IOMI, AORI, NOP, NOP, NOP, NOP, // 0100 - STA
MICO, ROIICE, IOAI, NOP, NOP, NOP, NOP, NOP, // 0101 - LDI
MICO, ROIICE, IOJ, NOP, NOP, NOP, NOP, NOP, // 0110 - JMP
MICO, ROIICE, NOP, NOP, NOP, NOP, NOP, NOP, // 0111 - JC
MICO, ROIICE, NOP, NOP, NOP, NOP, NOP, NOP, // 1000 - JZ
MICO, ROIICE, NOP, NOP, NOP, NOP, NOP, NOP, // 1001
MICO, ROIICE, NOP, NOP, NOP, NOP, NOP, NOP, // 1010
MICO, ROIICE, NOP, NOP, NOP, NOP, NOP, NOP, // 1011
MICO, ROIICE, NOP, NOP, NOP, NOP, NOP, NOP, // 1100
MICO, ROIICE, NOP, NOP, NOP, NOP, NOP, NOP, // 1101
MICO, ROIICE, AOOI, NOP, NOP, NOP, NOP, NOP, // 1110 - OUT
MICO, ROIICE, HLT, NOP, NOP, NOP, NOP, NOP, // 1111 - HLT
MICO, ROIICE, NOP, NOP, NOP, NOP, NOP, NOP, // 0000 - NOP (JC block)
MICO, ROIICE, IOMI, ROAI, NOP, NOP, NOP, NOP, // 0001 - LDA
MICO, ROIICE, IOMI, ROBI, EOAIFI, NOP, NOP, NOP, // 0010 - ADD
MICO, ROIICE, IOMI, ROBI, EOAISUFI, NOP, NOP, NOP, // 0011 - SUB
MICO, ROIICE, IOMI, AORI, NOP, NOP, NOP, NOP, // 0100 - STA
MICO, ROIICE, IOAI, NOP, NOP, NOP, NOP, NOP, // 0101 - LDI
MICO, ROIICE, IOJ, NOP, NOP, NOP, NOP, NOP, // 0110 - JMP
MICO, ROIICE, IOJ, NOP, NOP, NOP, NOP, NOP, // 0111 - JC
MICO, ROIICE, NOP, NOP, NOP, NOP, NOP, NOP, // 1000 - JZ
MICO, ROIICE, NOP, NOP, NOP, NOP, NOP, NOP, // 1001
MICO, ROIICE, NOP, NOP, NOP, NOP, NOP, NOP, // 1010
MICO, ROIICE, NOP, NOP, NOP, NOP, NOP, NOP, // 1011
MICO, ROIICE, NOP, NOP, NOP, NOP, NOP, NOP, // 1100
MICO, ROIICE, NOP, NOP, NOP, NOP, NOP, NOP, // 1101
MICO, ROIICE, AOOI, NOP, NOP, NOP, NOP, NOP, // 1110 - OUT
MICO, ROIICE, HLT, NOP, NOP, NOP, NOP, NOP, // 1111 - HLT
MICO, ROIICE, NOP, NOP, NOP, NOP, NOP, NOP, // 0000 - NOP (JZ block)
MICO, ROIICE, IOMI, ROAI, NOP, NOP, NOP, NOP, // 0001 - LDA
MICO, ROIICE, IOMI, ROBI, EOAIFI, NOP, NOP, NOP, // 0010 - ADD
MICO, ROIICE, IOMI, ROBI, EOAISUFI, NOP, NOP, NOP, // 0011 - SUB
MICO, ROIICE, IOMI, AORI, NOP, NOP, NOP, NOP, // 0100 - STA
MICO, ROIICE, IOAI, NOP, NOP, NOP, NOP, NOP, // 0101 - LDI
MICO, ROIICE, IOJ, NOP, NOP, NOP, NOP, NOP, // 0110 - JMP
MICO, ROIICE, NOP, NOP, NOP, NOP, NOP, NOP, // 0111 - JC
MICO, ROIICE, IOJ, NOP, NOP, NOP, NOP, NOP, // 1000 - JZ
MICO, ROIICE, NOP, NOP, NOP, NOP, NOP, NOP, // 1001
MICO, ROIICE, NOP, NOP, NOP, NOP, NOP, NOP, // 1010
MICO, ROIICE, NOP, NOP, NOP, NOP, NOP, NOP, // 1011
MICO, ROIICE, NOP, NOP, NOP, NOP, NOP, NOP, // 1100
MICO, ROIICE, NOP, NOP, NOP, NOP, NOP, NOP, // 1101
MICO, ROIICE, AOOI, NOP, NOP, NOP, NOP, NOP, // 1110 - OUT
MICO, ROIICE, HLT, NOP, NOP, NOP, NOP, NOP, // 1111 - HLT
MICO, ROIICE, NOP, NOP, NOP, NOP, NOP, NOP, // 0000 - NOP (JCJZ block)
MICO, ROIICE, IOMI, ROAI, NOP, NOP, NOP, NOP, // 0001 - LDA
MICO, ROIICE, IOMI, ROBI, EOAIFI, NOP, NOP, NOP, // 0010 - ADD
MICO, ROIICE, IOMI, ROBI, EOAISUFI, NOP, NOP, NOP, // 0011 - SUB
MICO, ROIICE, IOMI, AORI, NOP, NOP, NOP, NOP, // 0100 - STA
MICO, ROIICE, IOAI, NOP, NOP, NOP, NOP, NOP, // 0101 - LDI
MICO, ROIICE, IOJ, NOP, NOP, NOP, NOP, NOP, // 0110 - JMP
MICO, ROIICE, IOJ, NOP, NOP, NOP, NOP, NOP, // 0111 - JC
MICO, ROIICE, IOJ, NOP, NOP, NOP, NOP, NOP, // 1000 - JZ
MICO, ROIICE, NOP, NOP, NOP, NOP, NOP, NOP, // 1001
MICO, ROIICE, NOP, NOP, NOP, NOP, NOP, NOP, // 1010
MICO, ROIICE, NOP, NOP, NOP, NOP, NOP, NOP, // 1011
MICO, ROIICE, NOP, NOP, NOP, NOP, NOP, NOP, // 1100
MICO, ROIICE, NOP, NOP, NOP, NOP, NOP, NOP, // 1101
MICO, ROIICE, AOOI, NOP, NOP, NOP, NOP, NOP, // 1110 - OUT
MICO, ROIICE, HLT, NOP, NOP, NOP, NOP, NOP, // 1111 - HLT
};
//Read a byte from the EEPROM at the specified address.
byte readEEPROM(int address)
{
for (int n = 0; n < 8; n += 1)
{
pinMode(datPin [n], INPUT);
}
// Set address to read from
for (int n= 0; n < 11; n++)
{
byte address = n;
digitalWrite(adrPin [n], address & 1);
address >>= 1;
}
byte data = 0;
for (int n = 0; n < 8; n += 1)
{
data = (data >> 1) + digitalRead(datPin[n]);
}
return data;
}
//Read the contents of the EEPROM and print them to the serial monitor.
void printContents()
{
for (int base = Begin; base <= End; base += 16)
{
byte data[16];
for (int offset = 0; offset <= 15; offset += 1)
{
data[offset] = readEEPROM(base + offset);
}
char buf[80];
sprintf(buf, "%03x: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x",
base, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7],
data[8], data[9], data[10], data[11], data[12], data[13], data[14], data[15]);
Serial.println(buf);
}
}
void setup()
{
// put your setup code here, to run once:
pinMode(WRITE_EN, OUTPUT);
digitalWrite(WRITE_EN, HIGH);
Serial.begin(57600);
Serial.flush();
while (!Serial) {;}
// Program data bytes
Serial.println("Programming EEPROM");
for (int address = 0; address < 1024; address += 1)
{
int flags = (address & 0b1100000000) >> 8;
int byte_sel = (address & 0b0010000000) >> 7;
int instruction = (address & 0b0001111000) >> 3;
int step = (address & 0b0000000111);
byte data = 0;
//Set Address pins to output
for (int n = 0; n <11; n++)
{
pinMode(adrPin [n], OUTPUT);
}
//Set address to write to
for (int n= 0; n < 11; n++)
{
byte address = n;
digitalWrite(adrPin [n], address & 1);
address >>= 1;
}
// Set Data pins to output
for (int n = 0; n <8; n++)
{
pinMode(datPin [n], OUTPUT);
}
if (byte_sel)
{
//Write byte to address //Low order bits
for (int n = 0; n <8; n += 1)
{
digitalWrite(datPin[n], data & 1);
data = data >> 1;
}
digitalWrite(WRITE_EN, LOW);
delayMicroseconds(1);
digitalWrite(WRITE_EN, HIGH);
delay(10);
} else
{
//Write byte to address //High order bits
for (int n = 0; n <8; n += 1)
{
digitalWrite(datPin[n], data >> 8 & 1);
data = data >> 1;
}
digitalWrite(WRITE_EN, LOW);
delayMicroseconds(1);
digitalWrite(WRITE_EN, HIGH);
delay(10);
}
}
// Read and print out the contents of the EEPROM
Serial.println("Reading EEPROM");
Serial.println("Z0C0 Block");
Serial.println("Read the 8 high-order bits of microcode from the first 128 bytes of EEPROM");
Begin = 0;
End = 127;
printContents();
Serial.println("Read the 8 low-order bits of microcode from the second 128 bytes of EEPROM");
Begin = 128;
End = 255;
printContents();
Serial.println("Z0C1 Block");
Serial.println("Read the 8 high-order bits of microcode from the third 128 bytes of EEPROM");
Begin = 256;
End = 383;
printContents();
Serial.println("Read the 8 low-order bits of microcode from the fourth 128 bytes of EEPROM");
Begin = 384;
End = 511;
printContents();
Serial.println("Z1C0 Block");
Serial.println("Read the 8 high-order bits of microcode from the fifth 128 bytes of EEPROM");
Begin = 512;
End = 639;
printContents();
Serial.println("Read the 8 low-order bits of microcode from the sixth 128 bytes of EEPROM");
Begin = 640;
End = 767;
printContents();
Serial.println("Z1C1 Block");
Serial.println("Read the 8 high-order bits of microcode from the seventh 128 bytes of EEPROM");
Begin = 768;
End = 895;
printContents();
Serial.println("Read the 8 low-order bits of microcode from the eighth 128 bytes of EEPROM");
Begin = 896;
End = 1024;
printContents();
}
void loop() {
// put your main code here, to run repeatedly:
}
