Hi,
My project basic information as below:
Hardware:
MCU: KM34Z256
Three channel AFE channels used for current sampling
Three channel SAR ADC used for the voltage sampling
Target:
Use AFE and SAR ADC to sampling three phase AC current and voltage
Sampling process like below figure: Using AFE CH0 COCO to trigger the PDB module and PDB module to trigger the SAR ADC module.
Normally the process works well. But in debug mode, if I stop the MCU to check some values, then start again (not reset the MCU), sometime the SAR ADC seems not triggered any more, the SAR ADC result is not changed. But the AFE three channels work well. And there is an error in PDB module.
My question is:
1. How to avoid this error happen
2. If this error occurred, how to restore the PDB or SAR ADC?
Martin
Hi, Martin,
If you use debugger to intervene process that the PDB multiple channels trigger multiple channel ADC conversion in order, for example as you have done:
PDB_CH0 triggers ADC_RA
PDB_CH1 triggers ADC_RB
PDB_CH2 triggers ADC_RC
The order or sequence may be violated. For example, PDB_CH1 triggers ADC_RB while the ADC_RA conversion is in progress, the fact will leads to ERR bits are set in PDB_CH1S register.
As a workaround or for reliability, I suggest you use ADC interrupt, in the ISR of ADC, read the ADC sample and check if the ERR bits in multiple PDB_CHxS registers, if ERR bits are set, just write 0 to ERR bits so that the ADC plus PDB can work later, if your application required, set flag to mark the sample maybe has issue.
Hope it can help you
BR
Xiangjun Rong