Hi NXP community,
ADC0/ADC1 Interrupts Stop After Runtime Flash Erase/Program Operation on S32K144
As a continuation of my previous question, I need some clarification on how to properly recover from a PDB ADC pre-trigger sequence error on the S32K144.
I tried the following three methods, but only one of them worked correctly.
Method 1 (working):
With this approach, no PDB sequence error occurs.
Method 2:
After the flash erase/program operation was completed, I stopped and restarted PDB0 and PDB1. However, a PDB pre-trigger sequence error occurred. I then attempted to recover by stopping and restarting the PDB modules again, but the sequence error persisted.
Method 3:
Method 3 (Not Working):
I did not stop or restart PDB0 and PDB1 during the flash erase/program operation. Instead, after the operation completed, one pending PDB ISR and ADC ISR were triggered.
Inside the PDB ISR, I attempted to clear the sequence error flag using:
PDB0->CH[0].S &= (uint32_t)(~PDB_S_ERR_MASK);
The corresponding ADC ISR was then executed, and reading the ADC result register cleared the COCO flag. I expected this to prevent further pre-trigger sequence errors, but the issue still persisted and this method did not work.
Hi,
Clearing PDB_S_ERR alone is usually not sufficient to recover from a pre-trigger sequence error because the ADC/PDB sequence may already be out of synchronization. Based on your test results, preventing the condition by stopping the PDB before the flash operation and restarting it afterwards appears to be the most reliable approach.
If recovery is attempted after the error occurs, I would recommend ensuring that both the PDB and ADC state are fully re-synchronized. This may include disabling the PDB, clearing pending PDB status flags, ensuring all pending ADC conversion results have been read (COCO cleared), re-enabling the PDB, and reloading the configuration if required before triggering resumes.
According to the RM, the pre-trigger lock is released when the corresponding COCO flag is set, when the pre-trigger is disabled, or when the PDB is disabled, so a full PDB disable/enable sequence may also be worth investigating.
BR, Petr