I want to add ADC channel ADC0_SE13 to measure potentiometer voltage. To control speed of motor. I tried lot of things but unable to set it in PDB block properly. ADC properly configured in ProcessorExpert and then I have configured PDB0. I tried lot of combination but every time I am getting PDB0 Error in MCAT tool.
What I should do in below files? I am using k116 FOC 2sh example code.
1. What is proper settings required to achieve this.
2. ADC configuration in processor expert?
3. PDB configuration in processor expert?
4. code modification in periferals_config.c ?
5. code modification in main.c ?
6. code modifications in meas_s32k.c?
Objective:
1. Connect potentiometer as throttle control for speed.
2. Trigger ADC through PDB back to back.
3. Read ADC value in interrupt routine. Where current and Voltages are measured using meas.c.
4. Set speed according to throttle demand. In ADC interrupt routine. Which variable have speed?
This is configuration code where I am modifying few lines. and Processor expert.
void McuPdbConfig(void)
{
/* PDB0 module initialization */
PDB_DRV_Init(INST_PDB0, &pdb0_InitConfig0);
/* PDB0 CH0 pre-trigger initialization */
PDB_DRV_ConfigAdcPreTrigger(INST_PDB0, 0, &pdb0_AdcTrigInitConfig0);
PDB_DRV_ConfigAdcPreTrigger(INST_PDB0, 0, &pdb0_AdcTrigInitConfig1);
PDB_DRV_ConfigAdcPreTrigger(INST_PDB0, 0, &pdb0_AdcTrigInitConfig2);
>>>>>//PDB_DRV_ConfigAdcPreTrigger(INST_PDB0, 0, &pdb0_AdcTrigInitConfig3);
/* Set PDB0 modulus value */
PDB_DRV_SetTimerModulusValue(INST_PDB0, 7800);
PDB_DRV_SetAdcPreTriggerDelayValue(INST_PDB0, 0, 0, 0);
PDB_DRV_SetAdcPreTriggerDelayValue(INST_PDB0, 0, 1, 1200);
>>>>//PDB_DRV_SetAdcPreTriggerDelayValue(INST_PDB0, 0, 2, 2400);
Screenshot from 2023-09-27 11-57-05.pngScreenshot from 2023-09-27 11-57-05.png
To add a potentiometer throttle via ADC0_SE13 using the PDB block in your S32K1xx motor control project, the core issue in the MCAT tool stems from channel allocation conflicts or misaligned pre-trigger sequence counts. In motor control (FOC 2-shunt), PDB channel 0 is typically heavily utilized for precise current sampling synchronized with the PWM reload. Adding a slow throttle measurement requires either a separate PDB channel (if available) or adding it as an independent pre-trigger sequence without disrupting the main PWM hardware triggers.