Just looking at the flash load/save functions, they seem complicated to me! I donât currently have a MUX, but saving/loading from flash donât disturb my analog reads.
This is how I do it, maybe this will help.
static OpdFlashConfig DSY_QSPI_BSS flashConfigLoad;
void UtilFlashSave()
{
uint32_t base = 0x90000000;
OpdFlashConfig flashConfigSave;// copy data to flashConfigSave struct
flashConfigSave.configVersion = FLASH_CONFIG_VERSION;
memcpy(&flashConfigSave.mixSynth, &mixSynth, sizeof(mixSynth));
flashConfigSave.mixDrum = mixDrum;memcpy(&flashConfigSave.synthSettings, &synthSettings, sizeof(synthSettings));
flashConfigSave.drumSettings = drumSettings;memcpy(&flashConfigSave.songStep, &songStep, sizeof(songStep));
flashConfigSave.seqSongLen = seqSongLen;memcpy(&flashConfigSave.seqBass, &seqBass, sizeof(seqBass));
memcpy(&flashConfigSave.seqLead, &seqLead, sizeof(seqLead));
memcpy(&flashConfigSave.seqLeadLen, &seqLeadLen, sizeof(seqLeadLen));
memcpy(&flashConfigSave.seqDrum, &seqDrum, sizeof(seqDrum));//memcpy(&flashConfigSave.lfo, &lfo, sizeof(lfo));
flashConfigSave.fxSettings = fxSettings;
memcpy(&flashConfigSave.seqBassGateTime, &seqBassGateTime, sizeof(seqBassGateTime));
memcpy(&flashConfigSave.seqVoiceOn, &seqVoiceOn, sizeof(seqVoiceOn));
flashConfigSave.sysTickBPM = sysTickBPM;// init and set mode
hardware.qspi_handle.mode = DSY_QSPI_MODE_INDIRECT_POLLING;
dsy_qspi_init(&hardware.qspi_handle);// erase
dsy_qspi_erase(base, base + sizeof(flashConfigSave));
// write
dsy_qspi_write(base, sizeof(flashConfigSave), (uint8_t*)&flashConfigSave);
// de-init
dsy_qspi_deinit();
}
void UtilFlashLoad()
{// init and set mode
hardware.qspi_handle.mode = DSY_QSPI_MODE_DSY_MEMORY_MAPPED;
dsy_qspi_init(&hardware.qspi_handle);// Flash is memory mapped so no need to read
// copy data from opdLoadConfig struct to data
if (flashConfigLoad.configVersion == FLASH_CONFIG_VERSION)
{
memcpy(&mixSynth, &flashConfigLoad.mixSynth, sizeof(mixSynth));
mixDrum = flashConfigLoad.mixDrum;memcpy(&synthSettings, &flashConfigLoad.synthSettings, sizeof(synthSettings)); drumSettings = flashConfigLoad.drumSettings; memcpy(&songStep, &flashConfigLoad.songStep, sizeof(songStep)); seqSongLen = flashConfigLoad.seqSongLen; memcpy(&seqBass, &flashConfigLoad.seqBass, sizeof(seqBass)); memcpy(&seqLead, &flashConfigLoad.seqLead, sizeof(seqLead)); memcpy(&seqLeadLen, &flashConfigLoad.seqLeadLen, sizeof(seqLeadLen)); memcpy(&seqDrum, &flashConfigLoad.seqDrum, sizeof(seqDrum)); //memcpy(&lfo, &flashConfigLoad.lfo, sizeof(lfo)); fxSettings = flashConfigLoad.fxSettings; memcpy(&seqBassGateTime, &flashConfigLoad.seqBassGateTime, sizeof(seqBassGateTime)); memcpy(&seqVoiceOn, &flashConfigLoad.seqVoiceOn, sizeof(seqVoiceOn)); sysTickBPM = flashConfigLoad.sysTickBPM;
}
// de-init
dsy_qspi_deinit();
}
Notice the
dsy_qspi_deinit();
at the end.
You are also polling your hardware extremely often in the for(;;)-loop in main(). Maybe try using a small delay in the loop, eg
System::Delay(25);
and see if this helps?