Skip to content

Indeximal's idea to remove the leading zeros, and use blank space instead. #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 79 additions & 36 deletions microcode-eeprom-programmer/microcode-eeprom-programmer.ino
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,13 @@ uint16_t data[] = {
* Output the address bits and outputEnable signal using shift registers.
*/
void setAddress(int address, bool outputEnable) {
shiftOut(SHIFT_DATA, SHIFT_CLK, MSBFIRST, (address >> 8) | (outputEnable ? 0x00 : 0x80));
shiftOut(SHIFT_DATA, SHIFT_CLK, MSBFIRST, address);
address = address & 0x7FFF;

byte msb = (address >> 8) | (outputEnable ? 0x00 : 0x80);
shiftOut(SHIFT_DATA, SHIFT_CLK, MSBFIRST, msb);

byte lsb = address & 0xFF;
shiftOut(SHIFT_DATA, SHIFT_CLK, MSBFIRST, lsb);

digitalWrite(SHIFT_LATCH, LOW);
digitalWrite(SHIFT_LATCH, HIGH);
Expand All @@ -67,7 +72,7 @@ byte readEEPROM(int address) {
}
setAddress(address, /*outputEnable*/ true);

byte data = 0;
byte data = 0x00;
for (int pin = EEPROM_D7; pin >= EEPROM_D0; pin -= 1) {
data = (data << 1) + digitalRead(pin);
}
Expand All @@ -94,24 +99,77 @@ void writeEEPROM(int address, byte data) {
delay(10);
}

/**
* Clear out the entire EEPROM
*/
void eraseEEPROM()
{
Serial.println("Erasing EEPROM");
for (int address = 0x0000; address < 0x0800; address++) {
writeEEPROM(address, 0xff);

if (address % 0x40 == 0x00) {
Serial.print(".");
}
}
Serial.println("Erasing EEPROM -- Done.");
Serial.println();
}


void programEEPROM(byte data[], int length)
{
Serial.println("Programming EEPROM");
for (int address = 0x0000; address < length; address++) {
writeEEPROM(address, data[address]);

if (address % 0x40 == 0x00) {
Serial.print(".");
}
}
Serial.println(" Done.");
Serial.println();
}


void programEEPROM(uint16_t data[], int offset, int length, bool highByte)
{
Serial.println("Programming EEPROM");
for (int address = 0x0000; address < length; address++){
byte value = data[address] >> (highByte ? 8 : 0);
writeEEPROM(address + offset, value);

if (address % 0x40 == 0x00) {
Serial.print(".");
}
}
Serial.println(" Done.");
Serial.println();
}


/*
* Read the contents of the EEPROM and print them to the serial monitor.
*/
void printContents() {
for (int base = 0; base <= 255; base += 16) {
byte data[16];
for (int offset = 0; offset <= 15; offset += 1) {
data[offset] = readEEPROM(base + offset);
void printContents(int address) {
for (int base = 0x0000; base < 0x0100; base += 0x10) {
char buf[20];
sprintf(buf, "0x%04x: ", address + base);
Serial.print(buf);
for (int offset = 0; offset < 0x10; offset += 0x01) {
byte data = readEEPROM(address + base + offset);
sprintf(buf, "%02x ", data);
Serial.print(buf);

if (offset == 0x07) {
Serial.print(" ");
}
}

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);
Serial.println();
}

Serial.println();
}


Expand All @@ -124,33 +182,18 @@ void setup() {
pinMode(WRITE_EN, OUTPUT);
Serial.begin(57600);

// Program data bytes
Serial.print("Programming EEPROM");

// Program the 8 high-order bits of microcode into the first 128 bytes of EEPROM
for (int address = 0; address < sizeof(data)/sizeof(data[0]); address += 1) {
writeEEPROM(address, data[address] >> 8);

if (address % 64 == 0) {
Serial.print(".");
}
}
// eraseEEPROM();

// Program the 8 low-order bits of microcode into the second 128 bytes of EEPROM
for (int address = 0; address < sizeof(data)/sizeof(data[0]); address += 1) {
writeEEPROM(address + 128, data[address]);

if (address % 64 == 0) {
Serial.print(".");
}
}

Serial.println(" done");
// Program data bytes
// Program the 8 high-order bits of microcode into the first 0x80 bytes of EEPROM
programEEPROM(data, 0x00, sizeof data / sizeof data[0], true);

// Program the 8 low-order bits of microcode into the second 0x80 bytes of EEPROM
programEEPROM(data, 0x80, sizeof data / sizeof data[0], false);

// Read and print out the contents of the EERPROM
Serial.println("Reading EEPROM");
printContents();
printContents(0x0000);
}


Expand Down
63 changes: 63 additions & 0 deletions multiplexed-display.tests/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto

###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp

###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary

###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary

###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain
Loading