CEL2_ CEL_ OEL_ and RWL_ moved to Atmega1284 Port C PIN_PC7 PIN_PC6 PIN_PC5 PIN_4

Port PD2 and PD3 used for Interrupts to count the Busy signals.
BusyFaultCount and ShadowFaultCount commands added to display the number
interrupts since the last Atmega1284 reboot.
BusyFault is counted when the live game RAM issues a busy to the Pinball 6802.
BusyFault would indicate a potential game crash.
ShadowFaultCount is recorded to get an idea how often the shadow memory might be
getting out of step with the game RAM.
The Shadow memory is updated with every read or write by the 6802.
The Shadow memory is not updated by a read or write to the game RAM from the memory port left side
Left side memory ports are for the ATMEGA 1284.
This commit is contained in:
Tim Gopaul 2023-02-19 14:01:08 -07:00
parent b56f142ac7
commit 79c30b9d0f
2 changed files with 76 additions and 4 deletions

View File

@ -1,4 +1,5 @@
/***************************************************************************** /*****************************************************************************
2023-01-18 Tim Gopaul add command BusyFaultCount to report how many Busy interrupts were generated since last reboot
2023-01-11/12 Tim Gopaul Removed getHexLineFromSerialPort.. use the main parsing code get command 2023-01-11/12 Tim Gopaul Removed getHexLineFromSerialPort.. use the main parsing code get command
2023-01-11 Tim Gopaul added call to make commands case insensitive. 2023-01-11 Tim Gopaul added call to make commands case insensitive.
2023-01-08 Tim Gopaul - add load command to read in Hex format string and place in RAM memory 2023-01-08 Tim Gopaul - add load command to read in Hex format string and place in RAM memory
@ -95,7 +96,8 @@
#include <errno.h> // https://stackoverflow.com/questions/26080829/detecting-strtol-failure when strtol fails it returns zero and an errno #include <errno.h> // https://stackoverflow.com/questions/26080829/detecting-strtol-failure when strtol fails it returns zero and an errno
#include <limits.h> // used to find LONG_MIN and LONG_MAX #include <limits.h> // used to find LONG_MIN and LONG_MAX
extern volatile unsigned int BusyFaultCount;
extern volatile unsigned int ShadowFaultCount;
//Function Prototypes from .ino file //Function Prototypes from .ino file
void writeAddress(unsigned int address, byte dataByte); void writeAddress(unsigned int address, byte dataByte);
@ -152,6 +154,9 @@ const char *gameReadCommandToken = "gameread"; // read address ignore
const char *gameWriteCommandToken = "gamewrite"; // write address byte const char *gameWriteCommandToken = "gamewrite"; // write address byte
const char *gameDumpCommandToken = "gameDump"; // Dumps game memory from starting address with byte count const char *gameDumpCommandToken = "gameDump"; // Dumps game memory from starting address with byte count
const char *BusyFaultCountToken = "busyfaultcount"; // displays the accumulative count of the busy interrupts
const char *ShadowFaultCountToken = "shadowfaultcount"; // displays the accumulative count of the busy interrupts
/************************************************************************************************************* /*************************************************************************************************************
getCommandLineFromSerialPort() getCommandLineFromSerialPort()
Return the string of the next command. Commands are delimited by return" Return the string of the next command. Commands are delimited by return"
@ -373,6 +378,13 @@ int gameDumpCommand() {
return addrStart; return addrStart;
} }
void busyFaultCountCommand(){
Serial.printf("> Cumlative fault count since last Atmega1284 reboot: %d\n", BusyFaultCount );
}
void shadowFaultCountCommand(){
Serial.printf("> Cumlative fault count since last Atmega1284 reboot: %d\n", ShadowFaultCount );
}
// ***** testMemmory ***** // ***** testMemmory *****
int testMemoryCommand(){ int testMemoryCommand(){
@ -527,6 +539,15 @@ DoMyCommand(char * commandLine) {
else if (strcasecmp(ptrToCommandName, testMemoryCommandToken) == 0) { //Modify here else if (strcasecmp(ptrToCommandName, testMemoryCommandToken) == 0) { //Modify here
result = testMemoryCommand(); result = testMemoryCommand();
} }
else if (strcasecmp(ptrToCommandName, BusyFaultCountToken) == 0) { //Modify here
busyFaultCountCommand();
}
else if (strcasecmp(ptrToCommandName, ShadowFaultCountToken) == 0) { //Modify here
shadowFaultCountCommand();
}
else { else {
nullCommand(ptrToCommandName); nullCommand(ptrToCommandName);
} }

View File

@ -1,7 +1,12 @@
// Protospace is running code version PinBallMemoryPort20230201 // Protospace is running code version PinBallMemoryPort20230201
// The next version of code starts dated 2023 02 05 // The next version of code starts dated 2023 02 05
// //
// 2023-02-05 Tim Gopaul,, look into moving control pins to PC // 2023-02-18 Tim Gopaul, trouble getting PCINT30 working. changed to interruptPin = PIN_PD2 which gives digitalPinToInterrupt(interruptPin) as 0
// 2023-02-14 Tim Gopaul, attach an interrupt low edge to pin 20 PD6 PCINT30
// connect interrupt to _BusyRight to indicate the Pinball live memory was issued a wait.. which likey corrupted game ram
// What to do. ..maybe save high score to portal then restart the pinball machine or issue a warning to the LCD screen
//
// 2023-02-05 Tim Gopaul,, look into moving control pins to PC done
// //
// //
// 2023-01-29 Tim Gopaul troubleshoot bad first byte read // 2023-01-29 Tim Gopaul troubleshoot bad first byte read
@ -85,7 +90,17 @@ int inputMode = 1;
#define CEL2_OEL_HIGH PORTC |=B10010000 // ChipEnable with OutputEnable HIGH PORTDPIN_PC7 PIN_PC4 #define CEL2_OEL_HIGH PORTC |=B10010000 // ChipEnable with OutputEnable HIGH PORTDPIN_PC7 PIN_PC4
const byte BUSY_ = PIN_PD7; // BUSY# input pull up const byte BUSY_ = PIN_PD7; // BUSY# input pull up This is for the Atmega side Busy signals
const byte BUSY_IRQPIN = PIN_PD2; //BUSY_FAULT will go low if the live game ram receives a Busy signal
volatile byte BusyStateIRQ = HIGH;
volatile unsigned int BusyFaultAddress;
volatile unsigned int BusyFaultCount = 0; // count the number of busy faults and report when given the BusyFaultCount command
const byte SHADOW_IRQPIN = PIN_PD3; //BUSY_FAULT will go low if the live game ram receives a Busy signal
volatile byte ShadowStateIRQ = HIGH;
volatile unsigned int ShadowFaultAddress;
volatile unsigned int ShadowFaultCount = 0; // count the number of busy faults and report when given the BusyFaultCount command
volatile byte ramBuffer[ramSize]; // This is an array to hold the contents of memory volatile byte ramBuffer[ramSize]; // This is an array to hold the contents of memory
@ -142,6 +157,13 @@ int helpText(){
Serial.println(">* Enter numbers as decimal or *"); Serial.println(">* Enter numbers as decimal or *");
Serial.println(">* 0xNN 0X55 for HEX *"); Serial.println(">* 0xNN 0X55 for HEX *");
Serial.println(">* *"); Serial.println(">* *");
Serial.println(">* BusyFaultCount will give the *");
Serial.println(">* count of Busy Interruptes *");
Serial.println(">* *");
Serial.println(">* ShadowFaultCount gives the *");
Serial.println(">* count of Shadow Busy *");
Serial.println(">* Interruptes *");
Serial.println(">* *");
Serial.println(">**********************************"); Serial.println(">**********************************");
Serial.println(); Serial.println();
return(0); return(0);
@ -752,11 +774,27 @@ void testMemory(unsigned int addrStart, unsigned int addrCount, int testLoops) {
} }
} }
void BusyFaultWarning(){
BusyStateIRQ = LOW;
++BusyFaultCount;
BusyFaultAddress = (((PORTC & B0000111) << 8 ) + PORTA);
}
void ShadowFaultWarning(){
ShadowStateIRQ = LOW;
++ShadowFaultCount;
ShadowFaultAddress = (((PORTC & B0000111) << 8 ) + PORTA);
}
// ***** setup ***** ----------------------------------------------- // ***** setup ***** -----------------------------------------------
void setup() { void setup() {
pinMode(BUSY_IRQPIN, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(BUSY_IRQPIN),BusyFaultWarning, FALLING);
pinMode(SHADOW_IRQPIN, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(SHADOW_IRQPIN),ShadowFaultWarning, FALLING);
// seed the random mumber generator // seed the random mumber generator
randomSeed(millis()); //initialize pseudo random number randomSeed(millis()); //initialize pseudo random number
@ -803,6 +841,19 @@ void setup() {
// ***** loop ***** ---------------------------------------- // ***** loop ***** ----------------------------------------
void loop() { void loop() {
if (BusyStateIRQ == LOW ) {
BusyStateIRQ = HIGH;
Serial.printf("\n> PIN_PD2 IRQ 0 Busy fault Live Game RAM issued a BUSY, Address: 0x%04X\n", BusyFaultAddress );
Serial.printf("> Cumlative fault count since last Atmega1284 reboot: %d\n", BusyFaultCount );
}
if (ShadowStateIRQ == LOW ) {
ShadowStateIRQ = HIGH;
Serial.printf("\n> PIN_PD3 IRQ 1 Busy fault Shadow RAM issued a BUSY, Address: 0x%04X\n", ShadowFaultAddress );
Serial.printf("> Cumlative Shadow fault count since last Atmega1284 reboot: %d\n", ShadowFaultCount );
}
bool received = getCommandLineFromSerialPort(CommandLine); //global CommandLine is defined in CommandLine.h bool received = getCommandLineFromSerialPort(CommandLine); //global CommandLine is defined in CommandLine.h
if (received) { if (received) {
switch(inputMode){ switch(inputMode){