ADC0/ADC1 Interrupts Stop After Runtime Flash Erase/Program Operation on S32K144

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ADC0/ADC1 Interrupts Stop After Runtime Flash Erase/Program Operation on S32K144

Jump to solution
309 Views
Jarvis_vk
Contributor I

Hello NXP Community,


Controller: S32K144

Scenario:

ADC0 and ADC1 are configured in hardware trigger mode using PDB and are running continuously as part of the application. During runtime, a 4 KB flash sector erase is performed in a reserved flash memory region, followed by programming of new data into the same sector. To avoid execution issues during flash erase, interrupts are disabled before starting the flash operation and re-enabled after the erase/program sequence is completed.

Observed Behavior:

When interrupts are re-enabled after the flash operation, the application continues to run normally. Other interrupt sources continue to execute as expected, indicating that global interrupt functionality is restored correctly. However, ADC0 and ADC1 interrupt handlers are no longer triggered after the flash erase/program operation. As a result, ADC sampling stops and the application no longer receives ADC conversion updates. The issue is observed consistently whenever a flash sector erase is performed during runtime.

Additional Observation: ADC operation can be restored by forcing a software-triggered ADC conversion, after which ADC interrupts start occurring again and normal operation resumes.

Query: Is there any known interaction between flash erase/program operations and PDB-triggered ADC conversions on S32K144? Are there any recommended steps to re-synchronize or recover the ADC/PDB trigger chain after a flash operation so that ADC conversions and interrupts resume normally?

0 Kudos
Reply
1 Solution
249 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

Looks like typical PDB/ADC chain stuck after flash operation. The fact that a software-triggered conversion restores operation suggests the ADC/PDB state machine is not dead, only out of sync after the flash sequence. 

  • During flash erase/program, if interrupts are disabled but PDB triggering is still active, ADC conversions may complete while results are not serviced/read, so COCO remains set. 
  • That can lead to PDB pretrigger lock / sequence error, after which further hardware-triggered conversions may stop. 
  • So it is worth asking whether ADC sampling is really needed during flash update. If not, the safer approach may be to stop/disable PDB triggering before flash operation and restart/re-sync it afterwards. 

Recommended checks/workaround:

  • check PDB error/lock flags after flash 
  • if sampling is not needed during flash, stop PDB before erase/program and enable it again afterwards
  • otherwise after flash do explicit recovery: stop PDB → clear ADC status/read pending results → clear PDB flags → restart trigger chain

So likely root cause is not NVIC itself, but unserviced ADC/PDB state during flash operation.

BR, Petr

View solution in original post

5 Replies
250 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

Looks like typical PDB/ADC chain stuck after flash operation. The fact that a software-triggered conversion restores operation suggests the ADC/PDB state machine is not dead, only out of sync after the flash sequence. 

  • During flash erase/program, if interrupts are disabled but PDB triggering is still active, ADC conversions may complete while results are not serviced/read, so COCO remains set. 
  • That can lead to PDB pretrigger lock / sequence error, after which further hardware-triggered conversions may stop. 
  • So it is worth asking whether ADC sampling is really needed during flash update. If not, the safer approach may be to stop/disable PDB triggering before flash operation and restart/re-sync it afterwards. 

Recommended checks/workaround:

  • check PDB error/lock flags after flash 
  • if sampling is not needed during flash, stop PDB before erase/program and enable it again afterwards
  • otherwise after flash do explicit recovery: stop PDB → clear ADC status/read pending results → clear PDB flags → restart trigger chain

So likely root cause is not NVIC itself, but unserviced ADC/PDB state during flash operation.

BR, Petr

246 Views
Jarvis_vk
Contributor I
Thanks for your reply, Petrs.

I implemented the suggested approach by stopping PDB0 and PDB1 before the flash erase/program operation and restarting them afterwards. After making this change, ADC0 and ADC1 interrupts resumed normal operation and the issue was resolved.
I would like to understand the root cause in more detail. Since interrupts were already disabled during the flash operation, I initially assumed that stopping PDB would not be necessary. Could you please explain why explicitly stopping PDB before the flash operation prevents this issue?
Also, is there any application note, reference manual section, or other supporting documentation that describes this behavior or the recommended handling of PDB-triggered ADC conversions during flash erase/program operations? I would like to understand the underlying mechanism and best practice for future implementations.

Thank you.
0 Kudos
Reply
232 Views
PetrS
NXP TechSupport
NXP TechSupport

Hi,

PDB pretrigger lock mechanism is described in chapter 46.4.1 PDB pre-trigger and trigger outputs of the device RM.

BR, Petr

0 Kudos
Reply
104 Views
Jarvis_vk
Contributor I
I went through the Reference Manual and found that if a PDB pretrigger occurs while the lock state is active, the corresponding ERR bit in PDB_CHnS is set. The RM also states that once an ERR condition occurs, further ADC pretriggers are halted until the error flag is cleared by writing 0.
Based on that, I expected that clearing the ERR bits would allow ADC pretriggers to resume. To verify this, I added debugging in the first ADC0 and ADC1 ISRs that occur after the flash erase operation.
• As mentioned earlier, after the flash erase completes and interrupts are re-enabled, I observe one ADC0 ISR and one ADC1 ISR execution. Inside these ISRs:
• I read the ADC result registers, which should clear the COCO status.
• I read the corresponding PDB0_CH[0].S and PDB1_CH[0].S registers.
• If the ERR bits are set, I clear them by writing the status register back to 0.

What I observed is:
Before the flash operation:
PDB0_CH[0].S = 0x700000
PDB1_CH[0].S = 0x700000
After the flash erase:
PDB0_CH[0].S = 0x700010
PDB1_CH[0].S = 0x700010
• In the first ADC ISR after the erase, I clear the ERR condition and both registers return to 0x700000.
• However, after the subsequent 8-byte flash program operation, both PDB status registers again change to 0x700010.
• After this point, no further ADC conversions complete and COCO is not set for either ADC.
Based on the RM description, I expected clearing the ERR condition to allow ADC pretriggers to resume, but that does not appear to happen in this case. Could you please help explain why the ERR condition reappears and whether any additional recovery sequence is required after flash erase/program operations when using PDB-triggered ADC conversions?

Currently, the only workaround that consistently resolves the issue is stopping PDB0/PDB1 before the flash erase/program operation and restarting them afterwards. Is this the recommended solution, or is there a more appropriate recovery sequence that should be used?
0 Kudos
Reply
255 Views
Jarvis_vk
Contributor I

One more observation:
After enabling the Global ISR when P flash erase complete, I have one cycle of triggering sequence
PDB ISR call back --> ADC 1 --->ADC 0 After that ADC ISR call back function is not triggered

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2376887%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EADC0%2FADC1%20Interrupts%20Stop%20After%20Runtime%20Flash%20Erase%2FProgram%20Operation%20on%20S32K144%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2376887%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CSPAN%3EHello%20NXP%20Community%2C%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%3CSTRONG%3EController%3C%2FSTRONG%3E%3A%20S32K144%3C%2FP%3E%3CP%3E%3CSTRONG%3EScenario%3A%20%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EADC0%20and%20ADC1%20are%20configured%20in%20hardware%20trigger%20mode%20using%20PDB%20and%20are%20running%20continuously%20as%20part%20of%20the%20application.%20During%20runtime%2C%20a%204%20KB%20flash%20sector%20erase%20is%20performed%20in%20a%20reserved%20flash%20memory%20region%2C%20followed%20by%20programming%20of%20new%20data%20into%20the%20same%20sector.%20To%20avoid%20execution%20issues%20during%20flash%20erase%2C%20interrupts%20are%20disabled%20before%20starting%20the%20flash%20operation%20and%20re-enabled%20after%20the%20erase%2Fprogram%20sequence%20is%20completed.%3C%2FP%3E%3CP%3E%3CSTRONG%3EObserved%20Behavior%3A%20%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EWhen%20interrupts%20are%20re-enabled%20after%20the%20flash%20operation%2C%20the%20application%20continues%20to%20run%20normally.%20Other%20interrupt%20sources%20continue%20to%20execute%20as%20expected%2C%20indicating%20that%20global%20interrupt%20functionality%20is%20restored%20correctly.%20However%2C%20ADC0%20and%20ADC1%20interrupt%20handlers%20are%20no%20longer%20triggered%20after%20the%20flash%20erase%2Fprogram%20operation.%20As%20a%20result%2C%20ADC%20sampling%20stops%20and%20the%20application%20no%20longer%20receives%20ADC%20conversion%20updates.%20The%20issue%20is%20observed%20consistently%20whenever%20a%20flash%20sector%20erase%20is%20performed%20during%20runtime.%3C%2FP%3E%3CP%3E%3CSTRONG%3EAdditional%20Observation%3C%2FSTRONG%3E%3A%20ADC%20operation%20can%20be%20restored%20by%20forcing%20a%20software-triggered%20ADC%20conversion%2C%20after%20which%20ADC%20interrupts%20start%20occurring%20again%20and%20normal%20operation%20resumes.%3C%2FP%3E%3CP%3E%3CSTRONG%3EQuery%3C%2FSTRONG%3E%3A%20Is%20there%20any%20known%20interaction%20between%20flash%20erase%2Fprogram%20operations%20and%20PDB-triggered%20ADC%20conversions%20on%20S32K144%3F%20Are%20there%20any%20recommended%20steps%20to%20re-synchronize%20or%20recover%20the%20ADC%2FPDB%20trigger%20chain%20after%20a%20flash%20operation%20so%20that%20ADC%20conversions%20and%20interrupts%20resume%20normally%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2377349%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20ADC0%2FADC1%20Interrupts%20Stop%20After%20Runtime%20Flash%20Erase%2FProgram%20Operation%20on%20S32K144%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2377349%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EThanks%20for%20your%20reply%2C%20Petrs.%3CBR%20%2F%3E%3CBR%20%2F%3EI%20implemented%20the%20suggested%20approach%20by%20stopping%20PDB0%20and%20PDB1%20before%20the%20flash%20erase%2Fprogram%20operation%20and%20restarting%20them%20afterwards.%20After%20making%20this%20change%2C%20ADC0%20and%20ADC1%20interrupts%20resumed%20normal%20operation%20and%20the%20issue%20was%20resolved.%3CBR%20%2F%3EI%20would%20like%20to%20understand%20the%20root%20cause%20in%20more%20detail.%20Since%20interrupts%20were%20already%20disabled%20during%20the%20flash%20operation%2C%20I%20initially%20assumed%20that%20stopping%20PDB%20would%20not%20be%20necessary.%20Could%20you%20please%20explain%20why%20explicitly%20stopping%20PDB%20before%20the%20flash%20operation%20prevents%20this%20issue%3F%3CBR%20%2F%3EAlso%2C%20is%20there%20any%20application%20note%2C%20reference%20manual%20section%2C%20or%20other%20supporting%20documentation%20that%20describes%20this%20behavior%20or%20the%20recommended%20handling%20of%20PDB-triggered%20ADC%20conversions%20during%20flash%20erase%2Fprogram%20operations%3F%20I%20would%20like%20to%20understand%20the%20underlying%20mechanism%20and%20best%20practice%20for%20future%20implementations.%3CBR%20%2F%3E%3CBR%20%2F%3EThank%20you.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2377261%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20ADC0%2FADC1%20Interrupts%20Stop%20After%20Runtime%20Flash%20Erase%2FProgram%20Operation%20on%20S32K144%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2377261%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%2C%3C%2FP%3E%0A%3CDIV%3E%0A%3CP%3ELooks%20like%20typical%20PDB%2FADC%20chain%20stuck%20after%20flash%20operation.%20The%20fact%20that%20a%20software-triggered%20conversion%20restores%20operation%20suggests%20the%20ADC%2FPDB%20state%20machine%20is%20not%20dead%2C%20only%20out%20of%20sync%20after%20the%20flash%20sequence.%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EDuring%20flash%20erase%2Fprogram%2C%20if%20interrupts%20are%20disabled%20but%20PDB%20triggering%20is%20still%20active%2C%20ADC%20conversions%20may%20complete%20while%20results%20are%20not%20serviced%2Fread%2C%20so%20COCO%20remains%20set.%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3EThat%20can%20lead%20to%20PDB%20pretrigger%20lock%20%2F%20sequence%20error%2C%20after%20which%20further%20hardware-triggered%20conversions%20may%20stop.%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3ESo%20it%20is%20worth%20asking%20whether%20ADC%20sampling%20is%20really%20needed%20during%20flash%20update.%20If%20not%2C%20the%20safer%20approach%20may%20be%20to%20stop%2Fdisable%20PDB%20triggering%20before%20flash%20operation%20and%20restart%2Fre-sync%20it%20afterwards.%26nbsp%3B%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3ERecommended%20checks%2Fworkaround%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3Echeck%20PDB%20error%2Flock%20flags%20after%20flash%26nbsp%3B%3C%2FLI%3E%0A%3CLI%3Eif%20sampling%20is%20not%20needed%20during%20flash%2C%20stop%20PDB%20before%20erase%2Fprogram%20and%20enable%20it%20again%20afterwards%3C%2FLI%3E%0A%3CLI%3Eotherwise%20after%20flash%20do%20explicit%20recovery%3A%20stop%20PDB%20%E2%86%92%20clear%20ADC%20status%2Fread%20pending%20results%20%E2%86%92%20clear%20PDB%20flags%20%E2%86%92%20restart%20trigger%20chain%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3ESo%20likely%20root%20cause%20is%20not%20NVIC%20itself%2C%20but%20unserviced%20ADC%2FPDB%20state%20during%20flash%20operation.%3C%2FP%3E%0A%3CP%3EBR%2C%20Petr%3C%2FP%3E%0A%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2377237%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20ADC0%2FADC1%20Interrupts%20Stop%20After%20Runtime%20Flash%20Erase%2FProgram%20Operation%20on%20S32K144%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2377237%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EOne%20more%20observation%3A%3CBR%20%2F%3EAfter%20enabling%20the%20Global%20ISR%20when%20P%20flash%20erase%20complete%2C%20I%20have%20one%20cycle%20of%20triggering%20sequence%3CBR%20%2F%3EPDB%20ISR%20call%20back%20--%26gt%3B%20ADC%201%20---%26gt%3BADC%200%20After%20that%20ADC%20ISR%20call%20back%20function%20is%20not%20triggered%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2377484%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20ADC0%2FADC1%20Interrupts%20Stop%20After%20Runtime%20Flash%20Erase%2FProgram%20Operation%20on%20S32K144%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2377484%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%2C%3C%2FP%3E%0A%3CP%3EPDB%20pretrigger%20lock%20mechanism%20is%20described%20in%20chapter%26nbsp%3B46.4.1%20PDB%20pre-trigger%20and%20trigger%20outputs%20of%20the%20device%20RM.%3C%2FP%3E%0A%3CP%3EBR%2C%20Petr%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2378257%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20ADC0%2FADC1%20Interrupts%20Stop%20After%20Runtime%20Flash%20Erase%2FProgram%20Operation%20on%20S32K144%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2378257%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EI%20went%20through%20the%20Reference%20Manual%20and%20found%20that%20if%20a%20PDB%20pretrigger%20occurs%20while%20the%20lock%20state%20is%20active%2C%20the%20corresponding%20ERR%20bit%20in%20PDB_CHnS%20is%20set.%20The%20RM%20also%20states%20that%20once%20an%20ERR%20condition%20occurs%2C%20further%20ADC%20pretriggers%20are%20halted%20until%20the%20error%20flag%20is%20cleared%20by%20writing%200.%3CBR%20%2F%3EBased%20on%20that%2C%20I%20expected%20that%20clearing%20the%20ERR%20bits%20would%20allow%20ADC%20pretriggers%20to%20resume.%20To%20verify%20this%2C%20I%20added%20debugging%20in%20the%20first%20ADC0%20and%20ADC1%20ISRs%20that%20occur%20after%20the%20flash%20erase%20operation.%3CBR%20%2F%3E%E2%80%A2%20As%20mentioned%20earlier%2C%20after%20the%20flash%20erase%20completes%20and%20interrupts%20are%20re-enabled%2C%20I%20observe%20one%20ADC0%20ISR%20and%20one%20ADC1%20ISR%20execution.%20Inside%20these%20ISRs%3A%3CBR%20%2F%3E%E2%80%A2%20I%20read%20the%20ADC%20result%20registers%2C%20which%20should%20clear%20the%20COCO%20status.%3CBR%20%2F%3E%E2%80%A2%20I%20read%20the%20corresponding%20PDB0_CH%5B0%5D.S%20and%20PDB1_CH%5B0%5D.S%20registers.%3CBR%20%2F%3E%E2%80%A2%20If%20the%20ERR%20bits%20are%20set%2C%20I%20clear%20them%20by%20writing%20the%20status%20register%20back%20to%200.%3CBR%20%2F%3E%3CBR%20%2F%3EWhat%20I%20observed%20is%3A%3CBR%20%2F%3EBefore%20the%20flash%20operation%3A%3CBR%20%2F%3EPDB0_CH%5B0%5D.S%20%3D%200x700000%3CBR%20%2F%3EPDB1_CH%5B0%5D.S%20%3D%200x700000%3CBR%20%2F%3EAfter%20the%20flash%20erase%3A%3CBR%20%2F%3EPDB0_CH%5B0%5D.S%20%3D%200x700010%3CBR%20%2F%3EPDB1_CH%5B0%5D.S%20%3D%200x700010%3CBR%20%2F%3E%E2%80%A2%20In%20the%20first%20ADC%20ISR%20after%20the%20erase%2C%20I%20clear%20the%20ERR%20condition%20and%20both%20registers%20return%20to%200x700000.%3CBR%20%2F%3E%E2%80%A2%20However%2C%20after%20the%20subsequent%208-byte%20flash%20program%20operation%2C%20both%20PDB%20status%20registers%20again%20change%20to%200x700010.%3CBR%20%2F%3E%E2%80%A2%20After%20this%20point%2C%20no%20further%20ADC%20conversions%20complete%20and%20COCO%20is%20not%20set%20for%20either%20ADC.%3CBR%20%2F%3EBased%20on%20the%20RM%20description%2C%20I%20expected%20clearing%20the%20ERR%20condition%20to%20allow%20ADC%20pretriggers%20to%20resume%2C%20but%20that%20does%20not%20appear%20to%20happen%20in%20this%20case.%20Could%20you%20please%20help%20explain%20why%20the%20ERR%20condition%20reappears%20and%20whether%20any%20additional%20recovery%20sequence%20is%20required%20after%20flash%20erase%2Fprogram%20operations%20when%20using%20PDB-triggered%20ADC%20conversions%3F%3CBR%20%2F%3E%3CBR%20%2F%3ECurrently%2C%20the%20only%20workaround%20that%20consistently%20resolves%20the%20issue%20is%20stopping%20PDB0%2FPDB1%20before%20the%20flash%20erase%2Fprogram%20operation%20and%20restarting%20them%20afterwards.%20Is%20this%20the%20recommended%20solution%2C%20or%20is%20there%20a%20more%20appropriate%20recovery%20sequence%20that%20should%20be%20used%3F%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E