When testing I replace the WRITE_PRG command with an EXEC_FROM_RAM and this works correctly. As you can see from the code fragment below, the routine pauses after each program is sent to the FX Core and I can play test it before hitting a button to go on to the next program. After the last program the FX Core does return to the Run state, and I can hear the program that is currently selected on the 'Program Select' switch on the Dev Board.
Code: Select all
void programAllFlash() {
// readFXCoreStatus();
// Calculate the number of FXCore programs in the code arrays
uint8_t DSPprograms = sizeof(prgSize) / sizeof(prgSize[0]);
tft.fillScreen(BLACK);
tft.setTextSize(2);
for (uint8_t i = 0; i < DSPprograms; i++) {
tft.setCursor(0, 120);
tft.print("Flashing Program ");
tft.print(i);
flashProgram(i, i); // Here we call the flashProgram() function for each of our programs in the FXCPrograms.h file
delay(10);
}
// Refresh the display
displayPatchNumber(PATCHFONT, CYAN);
displayPatchName(isUserPatch, BIGFONT, CYAN);
displayProgamName(isUserPatch);
displayKnobLabels(ThisPatch.FXCoreProgram);
clearLeftOfCentreLine();
displayHeads();
for (int p = 0; p < NUMPOTS; p++) {
displayAnalogValue(BIGFONT, KNOB_NORMAL_COLOR, p * knobSpacing, ThisPatch.param[p + 1]);
}
}
// Write the given program to the specified FXCore Flash Memory
// unit8_t program = DSP program number (0-15)
// unit8_t location = FXCore Flash memory location to program (0-15)
void flashProgram(uint8_t program, uint8_t location) {
// Comment out the next line to test in RAM rather than writing to FLASH
#define WRITE_FLASH
EnterPRGmode(); // Tell the FXCore to get ready to receive a program
delay(10); // Allow the FXCore a little time to be ready
// Send the registers
sendCREGS(cregList[program]);
sendMREGS(mregList[program]);
sendSFR(sfrList[program]);
// Send the program data to the FXCore (RAM)
sendPROG(prgList[program], (prgSize[program] - 2) / 4);
delay(10);
#ifndef WRITE_FLASH
// For testing just execute the program from RAM
ExecuteFromRAM();
delay(10);
boolean UPpressed = false;
boolean DOWNpressed = false;
while (!UPpressed && !DOWNpressed) {
UPpressed = !digitalRead(UPSW_PIN);
DOWNpressed = !digitalRead(DOWNSW_PIN);
}
#else
// Tell the FXCore to write the program to the specified FLASH location
writeProg(location);
delay(10);
#endif
ReturnFXCoreToState0();
ExitProgram();
}
Any idea what I am doing wrong?
When testing with EXEC_FROM_RAM
12:27:44.111 -> sendPROG - Number of FXCore instructions: 70
12:27:44.149 -> Sent EXEC_FROM_RAM cmd: FX Core returned: OK
12:27:47.850 -> Sent RETURN_0 cmd: FX Core returned: 0
12:27:47.850 -> Sent EXIT_PRG cmd: FX Core returned: 0
12:27:47.991 -> sendPROG - Number of FXCore instructions: 91
12:27:48.037 -> Sent EXEC_FROM_RAM cmd: FX Core returned: OK
12:27:50.490 -> Sent RETURN_0 cmd: FX Core returned: 0
12:27:50.490 -> Sent EXIT_PRG cmd: FX Core returned: 0
When writing to FLASH location
12:32:53.819 -> sendPROG - Number of FXCore instructions: 70
12:32:53.866 -> Write to location 11 command sent. FXCore returned: 0x0
12:32:53.866 -> Sent RETURN_0 cmd: FX Core returned: 2
12:32:53.866 -> Sent EXIT_PRG cmd: FX Core returned: 2
12:32:54.005 -> sendPROG - Number of FXCore instructions: 91
12:32:54.037 -> Write to location 12 command sent. FXCore returned: 0x0
12:32:54.084 -> Sent RETURN_0 cmd: FX Core returned: 2
12:32:54.084 -> Sent EXIT_PRG cmd: FX Core returned: 2