forked from Apple-2-HW/TommyPROM
optimize Ben Eater unlock setAddress timing
This commit is contained in:
parent
e4c06537e9
commit
dd846ce085
BIN
docs/images/ben-eater-unlock-timing.png
Normal file
BIN
docs/images/ben-eater-unlock-timing.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 70 KiB |
@ -13,3 +13,8 @@ but would require changes for other platforms.
|
||||
|
||||
**NOTE** that this sketch **will not** work on TommyPROM hardware. It is included here
|
||||
to help people with locked chips who are using the Ben Eater design.
|
||||
|
||||
![Unlock timing with Ben Eater Hardware](../docs/images/ben-eater-unlock-timing.png)
|
||||
|
||||
The timing trace shows the tBLC for the bytes of the unlock sequence within 65us, well
|
||||
within the required 150us in the datasheet.
|
||||
|
@ -56,17 +56,50 @@ void loop() {
|
||||
|
||||
|
||||
// Output the address bits and outputEnable signal using shift registers.
|
||||
void setAddress(int address, bool outputEnable) {
|
||||
// Shift the address bits in
|
||||
shiftOut(SHIFT_DATA, SHIFT_CLK, MSBFIRST, (address >> 8) | (outputEnable ? 0x00 : 0x80));
|
||||
shiftOut(SHIFT_DATA, SHIFT_CLK, MSBFIRST, address);
|
||||
void setAddress(int addr, bool outputEnable) {
|
||||
// Set the highest bit as the output enable bit (active low)
|
||||
if (outputEnable) {
|
||||
addr &= ~0x8000;
|
||||
} else {
|
||||
addr |= 0x8000;
|
||||
}
|
||||
byte dataMask = 0x04;
|
||||
byte clkMask = 0x08;
|
||||
byte latchMask = 0x10;
|
||||
|
||||
// Make sure the clock is low to start.
|
||||
PORTD &= ~clkMask;
|
||||
|
||||
// Shift 16 bits in, starting with the MSB.
|
||||
for (uint16_t ix = 0; (ix < 16); ix++)
|
||||
{
|
||||
// Set the data bit
|
||||
if (addr & 0x8000)
|
||||
{
|
||||
PORTD |= dataMask;
|
||||
}
|
||||
else
|
||||
{
|
||||
PORTD &= ~dataMask;
|
||||
}
|
||||
|
||||
// Toggle the clock high then low
|
||||
PORTD |= clkMask;
|
||||
delayMicroseconds(3);
|
||||
PORTD &= ~clkMask;
|
||||
addr <<= 1;
|
||||
}
|
||||
|
||||
// Latch the shift register contents into the output register.
|
||||
digitalWrite(SHIFT_LATCH, LOW);
|
||||
digitalWrite(SHIFT_LATCH, HIGH);
|
||||
digitalWrite(SHIFT_LATCH, LOW);
|
||||
PORTD &= ~latchMask;
|
||||
delayMicroseconds(1);
|
||||
PORTD |= latchMask;
|
||||
delayMicroseconds(1);
|
||||
PORTD &= ~latchMask;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Read a byte from the EEPROM at the specified address.
|
||||
byte readEEPROM(int address) {
|
||||
setDataBusMode(INPUT);
|
||||
|
Loading…
Reference in New Issue
Block a user