From 18bb15bec664229016cd45971e0b421ff296a840 Mon Sep 17 00:00:00 2001 From: Tom Nisbet Date: Fri, 3 May 2024 23:04:59 -0400 Subject: [PATCH] update 27_CE algorithm for overwrite pulses --- TommyPROM/PromDevice27.cpp | 21 ++++++++++++++++----- TommyPROM/PromDevice27.h | 2 +- TommyPROM/TommyPROM.ino | 23 ++++++++++++++++++++++- docs/_docs/ref-900-release-history.md | 1 + 4 files changed, 40 insertions(+), 7 deletions(-) diff --git a/TommyPROM/PromDevice27.cpp b/TommyPROM/PromDevice27.cpp index ae10394..0125e22 100644 --- a/TommyPROM/PromDevice27.cpp +++ b/TommyPROM/PromDevice27.cpp @@ -130,7 +130,7 @@ bool PromDevice27::burnByteWE(byte value, uint32_t address) writeDataBus(value); delayMicroseconds(1); enableWrite(); - myDelay(mPulseWidthUsec * mOverwriteMultiplier); + myDelay(mPulseWidthUsec * mOverwriteMultiplier * (writeCount + 1)); disableWrite(); } @@ -179,7 +179,18 @@ bool PromDevice27::burnByteCE(byte value, uint32_t address) enableOutput(); status = readDataBus() == value; disableOutput(); - } + } else { + status = true; + } + } + + if (status && (mOverwriteMultiplier > 0)) { + setDataBusMode(OUTPUT); + writeDataBus(value); + delayMicroseconds(1); + enableChip(); + myDelay(mPulseWidthUsec * mOverwriteMultiplier * (writeCount + 1)); + disableChip(); } setDataBusMode(INPUT); @@ -244,15 +255,15 @@ ERET PromDevice27::erase(uint32_t start, uint32_t end) } -void PromDevice27::myDelay(unsigned int us) +void PromDevice27::myDelay(uint32_t us) { if (us > 16000) { // The delayMicroseconds code can't do delays longer than 16ms, so use the // ms delay code for larger values. This rounds down to the nearest ms, so // it is not possible to delay for 40.5 ms, for example. - delay(us / 1000); + delay(uint16_t(us / 1000)); } else { - delayMicroseconds((unsigned int) us); + delayMicroseconds(uint16_t(us)); } } diff --git a/TommyPROM/PromDevice27.h b/TommyPROM/PromDevice27.h index 7421390..7a439be 100644 --- a/TommyPROM/PromDevice27.h +++ b/TommyPROM/PromDevice27.h @@ -50,7 +50,7 @@ class PromDevice27 : public PromDevice bool burnByteWE(byte value, uint32_t address); bool burnByteCE(byte value, uint32_t address); - void myDelay(unsigned int us); + void myDelay(uint32_t us); E27C_PGM mPgmType; unsigned long mPulseWidthUsec; diff --git a/TommyPROM/TommyPROM.ino b/TommyPROM/TommyPROM.ino index 5507550..84169af 100644 --- a/TommyPROM/TommyPROM.ino +++ b/TommyPROM/TommyPROM.ino @@ -19,7 +19,7 @@ #include "XModem.h" -static const char * MY_VERSION = "3.6"; +static const char * MY_VERSION = "3.7"; // Global status @@ -49,6 +49,7 @@ PromDevice28C prom(32 * 1024L, 64, 10, true); //PromDevice27 prom(8 * 1024L, E27C_PGM_WE, 1000L, 15, 4); // 2764 with SEEQ intelligent programming //PromDevice27 prom(32 * 1024L, E27C_PGM_WE, 1000L, 25, 3); // 27C256 with SEEQ intelligent programming PromDevice27 prom(32 * 1024L, E27C_PGM_CE, 100L, 25, 0); // M27C256 with Presto II intelligent programming +//PromDevice27 prom(32 * 1024L, E27C_PGM_CE, 1000L, 25, 3); // M27256 with fast programming //PromDevice27 prom(2 * 1024L, E27C_PGM_WE, 50000L, 1, 0); // 2716 with single 50ms write //PromDevice27 prom(512 * 1024L, E27C_PGM_CE, 100L, 11, 0); // 27C040 with Atmel rapid programming, CE connected to CE#/PGM# //PromDevice27 prom(32 * 1024L, E27C_PGM_CE, 100L, 25, 0); // W27C257/W27E257 with 100uS program pulse on CE @@ -337,6 +338,7 @@ bool checkForBreak() word checksumBlock(uint32_t start, uint32_t end) { word checksum = 0; +#if 1 for (uint32_t addr = start; (addr <= end); addr += 2) { word w = prom.readData(addr); @@ -344,6 +346,25 @@ word checksumBlock(uint32_t start, uint32_t end) w |= prom.readData(addr + 1); checksum += w; } +#else + uint16_t crc = 0xffff; + for (uint32_t addr = start; (addr <= end); addr++) + { + crc = crc ^ (uint16_t(prom.readData(addr)) << 8); + for (int ix = 0; (ix < 8); ix++) + { + if (crc & 0x8000) + { + crc = (crc << 1) ^ 0x1021; + } + else + { + crc <<= 1; + } + } + } + checksum = crc; +#endif return checksum; } diff --git a/docs/_docs/ref-900-release-history.md b/docs/_docs/ref-900-release-history.md index e64a148..617a7dc 100644 --- a/docs/_docs/ref-900-release-history.md +++ b/docs/_docs/ref-900-release-history.md @@ -30,3 +30,4 @@ exerpt: "What's New in TommyPROM" |3.4 |2024-04-09 |Support 2316,2332, and 2364 mask-programmed ROMs| |3.5 |2024-04-12 |jcranes's updates to CLI for better parameter defaults and additional error checking| |3.6 |2024-04-23 |Remove debug commands by default - can be enabled in Configure.h| +|3.7 |2024-05-03 |Change overwrite algorithm for 27 series to match SEEQ and M27256 datasheets|