mirror of
https://github.com/TomNisbet/TommyPROM.git
synced 2024-09-27 06:55:08 +00:00
Fix #17 - pulse both CE and OE during the write verify cycle.
This commit is contained in:
parent
3c4de71cd8
commit
e45f1e3377
@ -66,6 +66,22 @@ bool PromDevice::writeData(byte data[], uint32_t len, uint32_t address)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PromDevice::resetDebugStats() {
|
||||||
|
debugBlockWrites = 0;
|
||||||
|
debugLastAddress = 0;
|
||||||
|
debugLastExpected = 0;
|
||||||
|
debugLastReadback = 0;
|
||||||
|
}
|
||||||
|
void PromDevice::printDebugStats() {
|
||||||
|
Serial.print(F("debugBlockWrites: "));
|
||||||
|
Serial.println(debugBlockWrites);
|
||||||
|
Serial.print(F("debugLastAddress: "));
|
||||||
|
Serial.println(debugLastAddress, HEX);
|
||||||
|
Serial.print(F("debugLastExpected: "));
|
||||||
|
Serial.println(debugLastExpected, HEX);
|
||||||
|
Serial.print(F("debugLastReadback: "));
|
||||||
|
Serial.println(debugLastReadback, HEX);
|
||||||
|
}
|
||||||
|
|
||||||
// BEGIN PRIVATE METHODS
|
// BEGIN PRIVATE METHODS
|
||||||
//
|
//
|
||||||
@ -105,5 +121,3 @@ void PromDevice::writeDataBus(byte data)
|
|||||||
PORTB = (PORTB & 0xfc) | (data >> 6);
|
PORTB = (PORTB & 0xfc) | (data >> 6);
|
||||||
PORTD = (PORTD & 0x03) | (data << 2);
|
PORTD = (PORTD & 0x03) | (data << 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,6 +20,8 @@ class PromDevice
|
|||||||
PromDevice(uint32_t size, word blockSize, unsigned maxWriteTime, bool polling);
|
PromDevice(uint32_t size, word blockSize, unsigned maxWriteTime, bool polling);
|
||||||
bool writeData(byte data[], uint32_t len, uint32_t address);
|
bool writeData(byte data[], uint32_t len, uint32_t address);
|
||||||
byte readData(uint32_t address) { return readByte(address); }
|
byte readData(uint32_t address) { return readByte(address); }
|
||||||
|
void resetDebugStats();
|
||||||
|
void printDebugStats();
|
||||||
|
|
||||||
virtual void begin() = 0;
|
virtual void begin() = 0;
|
||||||
virtual const char * getName() = 0;
|
virtual const char * getName() = 0;
|
||||||
@ -32,6 +34,11 @@ class PromDevice
|
|||||||
unsigned int mMaxWriteTime; // Max time (in ms) to wait for write cycle to complete
|
unsigned int mMaxWriteTime; // Max time (in ms) to wait for write cycle to complete
|
||||||
bool mSupportsDataPoll; // End of write detected by data polling
|
bool mSupportsDataPoll; // End of write detected by data polling
|
||||||
|
|
||||||
|
uint32_t debugBlockWrites; // Number of block write operations
|
||||||
|
uint32_t debugLastAddress; // Last address with an issue
|
||||||
|
uint8_t debugLastExpected; // Last expected readback value
|
||||||
|
uint8_t debugLastReadback; // Last actual readback value
|
||||||
|
|
||||||
void setDataBusMode(uint8_t mode);
|
void setDataBusMode(uint8_t mode);
|
||||||
byte readDataBus();
|
byte readDataBus();
|
||||||
void writeDataBus(byte data);
|
void writeDataBus(byte data);
|
||||||
@ -45,4 +52,3 @@ class PromDevice
|
|||||||
|
|
||||||
|
|
||||||
#endif // #define INCLUDE_PROM_DEVICE_H
|
#endif // #define INCLUDE_PROM_DEVICE_H
|
||||||
|
|
||||||
|
@ -138,9 +138,9 @@ bool PromDevice28C::burnByte(byte value, uint32_t address)
|
|||||||
bool PromDevice28C::burnBlock(byte data[], uint32_t len, uint32_t address)
|
bool PromDevice28C::burnBlock(byte data[], uint32_t len, uint32_t address)
|
||||||
{
|
{
|
||||||
bool status = false;
|
bool status = false;
|
||||||
|
|
||||||
if (len == 0) return true;
|
if (len == 0) return true;
|
||||||
|
|
||||||
|
++debugBlockWrites;
|
||||||
disableOutput();
|
disableOutput();
|
||||||
disableWrite();
|
disableWrite();
|
||||||
enableChip();
|
enableChip();
|
||||||
@ -162,6 +162,9 @@ bool PromDevice28C::burnBlock(byte data[], uint32_t len, uint32_t address)
|
|||||||
status = waitForWriteCycleEnd(data[len - 1]);
|
status = waitForWriteCycleEnd(data[len - 1]);
|
||||||
disableChip();
|
disableChip();
|
||||||
|
|
||||||
|
if (!status) {
|
||||||
|
debugLastAddress = address + len - 1;
|
||||||
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,29 +177,36 @@ bool PromDevice28C::waitForWriteCycleEnd(byte lastValue)
|
|||||||
// value written twice in a row. The D7 bit will read the inverse of last written
|
// value written twice in a row. The D7 bit will read the inverse of last written
|
||||||
// data and the D6 bit will toggle on each read while in programming mode.
|
// data and the D6 bit will toggle on each read while in programming mode.
|
||||||
//
|
//
|
||||||
// Note that the max readcount is set to the device's maxReadTime (in uSecs)
|
// This loop code takes about 18uSec to execute. The max readcount is set to the
|
||||||
// divided by two because there are two 1 uSec delays in the loop. In reality,
|
// device's maxReadTime (in uSecs) divided by ten rather than eighteen to ensure
|
||||||
// the loop could run for longer because this does not account for the time needed
|
// that it runs at least as long as the chip's timeout value, even if some code
|
||||||
// to run all of the loop code. In actual practice, the loop will terminate much
|
// optimizations are made later. In actual practice, the loop will terminate much
|
||||||
// earlier because it will detect the end of the write well before the max time.
|
// earlier because it will detect the end of the write well before the max time.
|
||||||
|
byte b1=0, b2=0;
|
||||||
setDataBusMode(INPUT);
|
setDataBusMode(INPUT);
|
||||||
delayMicroseconds(1);
|
delayMicroseconds(1);
|
||||||
for (int readCount = mMaxWriteTime * 1000 / 2; (readCount > 0); readCount--)
|
for (int readCount = 1; (readCount < (mMaxWriteTime * 100)); readCount++)
|
||||||
{
|
{
|
||||||
|
enableChip();
|
||||||
enableOutput();
|
enableOutput();
|
||||||
delayMicroseconds(1);
|
delayMicroseconds(1);
|
||||||
byte b1 = readDataBus();
|
b1 = readDataBus();
|
||||||
disableOutput();
|
disableOutput();
|
||||||
|
disableChip();
|
||||||
|
enableChip();
|
||||||
enableOutput();
|
enableOutput();
|
||||||
delayMicroseconds(1);
|
delayMicroseconds(1);
|
||||||
byte b2 = readDataBus();
|
b2 = readDataBus();
|
||||||
disableOutput();
|
disableOutput();
|
||||||
|
disableChip();
|
||||||
if ((b1 == b2) && (b1 == lastValue))
|
if ((b1 == b2) && (b1 == lastValue))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debugLastExpected = lastValue;
|
||||||
|
debugLastReadback = b2;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -224,4 +234,3 @@ void PromDevice28C::setByte(byte value, uint32_t address)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif // #if defined(PROM_IS_28C)
|
#endif // #if defined(PROM_IS_28C)
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include "XModem.h"
|
#include "XModem.h"
|
||||||
|
|
||||||
|
|
||||||
static const char * MY_VERSION = "2.3";
|
static const char * MY_VERSION = "2.4";
|
||||||
|
|
||||||
|
|
||||||
// Global status
|
// Global status
|
||||||
@ -84,6 +84,7 @@ enum {
|
|||||||
CMD_UNLOCK,
|
CMD_UNLOCK,
|
||||||
CMD_WRITE,
|
CMD_WRITE,
|
||||||
|
|
||||||
|
CMD_INFO,
|
||||||
CMD_SCAN,
|
CMD_SCAN,
|
||||||
CMD_TEST,
|
CMD_TEST,
|
||||||
CMD_ZAP,
|
CMD_ZAP,
|
||||||
@ -142,6 +143,7 @@ byte parseCommand(char c)
|
|||||||
case 'u': cmd = CMD_UNLOCK; break;
|
case 'u': cmd = CMD_UNLOCK; break;
|
||||||
case 'w': cmd = CMD_WRITE; break;
|
case 'w': cmd = CMD_WRITE; break;
|
||||||
|
|
||||||
|
case 'i': cmd = CMD_INFO; break;
|
||||||
case 's': cmd = CMD_SCAN; break;
|
case 's': cmd = CMD_SCAN; break;
|
||||||
case 't': cmd = CMD_TEST; break;
|
case 't': cmd = CMD_TEST; break;
|
||||||
case 'z': cmd = CMD_ZAP; break;
|
case 'z': cmd = CMD_ZAP; break;
|
||||||
@ -583,7 +585,6 @@ void zapTest(uint32_t start)
|
|||||||
0x00, 0xff, 0x55, 0xaa, '0', '1', '2', '3'
|
0x00, 0xff, 0x55, 0xaa, '0', '1', '2', '3'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
if (!prom.writeData(testData, sizeof(testData), start))
|
if (!prom.writeData(testData, sizeof(testData), start))
|
||||||
{
|
{
|
||||||
cmdStatus.error("Write failed");
|
cmdStatus.error("Write failed");
|
||||||
@ -676,6 +677,7 @@ void loop()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_FILL:
|
case CMD_FILL:
|
||||||
|
prom.resetDebugStats();
|
||||||
fillBlock(start, end, val);
|
fillBlock(start, end, val);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -685,6 +687,7 @@ void loop()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_POKE:
|
case CMD_POKE:
|
||||||
|
prom.resetDebugStats();
|
||||||
pokeBytes(line+1);
|
pokeBytes(line+1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -703,6 +706,7 @@ void loop()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_WRITE:
|
case CMD_WRITE:
|
||||||
|
prom.resetDebugStats();
|
||||||
Serial.println(F("Send the image file using XMODEM CRC"));
|
Serial.println(F("Send the image file using XMODEM CRC"));
|
||||||
numBytes = xmodem.ReceiveFile(start);
|
numBytes = xmodem.ReceiveFile(start);
|
||||||
if (numBytes)
|
if (numBytes)
|
||||||
@ -717,6 +721,10 @@ void loop()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef ENABLE_DEBUG_COMMANDS
|
#ifdef ENABLE_DEBUG_COMMANDS
|
||||||
|
case CMD_INFO:
|
||||||
|
prom.printDebugStats();
|
||||||
|
break;
|
||||||
|
|
||||||
case CMD_SCAN:
|
case CMD_SCAN:
|
||||||
scanBlock(start, end);
|
scanBlock(start, end);
|
||||||
break;
|
break;
|
||||||
@ -726,6 +734,7 @@ void loop()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_ZAP:
|
case CMD_ZAP:
|
||||||
|
prom.resetDebugStats();
|
||||||
zapTest(start);
|
zapTest(start);
|
||||||
break;
|
break;
|
||||||
#endif /* ENABLE_DEBUG_COMMANDS */
|
#endif /* ENABLE_DEBUG_COMMANDS */
|
||||||
@ -752,6 +761,7 @@ void loop()
|
|||||||
Serial.println(F(" Wsssss - Write to device from XMODEM CRC file"));
|
Serial.println(F(" Wsssss - Write to device from XMODEM CRC file"));
|
||||||
#ifdef ENABLE_DEBUG_COMMANDS
|
#ifdef ENABLE_DEBUG_COMMANDS
|
||||||
Serial.println();
|
Serial.println();
|
||||||
|
Serial.println(F(" I - Print debug Info"));
|
||||||
Serial.println(F(" Ssssss eeeee - Scan addresses (read each 10x)"));
|
Serial.println(F(" Ssssss eeeee - Scan addresses (read each 10x)"));
|
||||||
Serial.println(F(" Tsssss - Test read address (read 100x)"));
|
Serial.println(F(" Tsssss - Test read address (read 100x)"));
|
||||||
Serial.println(F(" Zsssss - Zap (burn) a 32 byte test pattern"));
|
Serial.println(F(" Zsssss - Zap (burn) a 32 byte test pattern"));
|
||||||
|
Loading…
Reference in New Issue
Block a user