Hi,
I am trying to sample 2 ADCs with 4 Channels each with 1 PDB module. i am trying to sample both ADCs continuously and send an interrupt on when the 4th Conversion is done (for each ADC) then write it to my terminal. I have multiple questions:
1. it samples only ADC0 one time and stops (ADC1 is not sampled at all and ADC0 is only sampled once). why?
2. The results are not written to my terminal. i programmed a print function in the ADC handler. why?
PS: i tried the continous mode for the pdb and the back to back mode for the pretriggers.
uint16_t pdbTimerVal;
char value[30];
if (LPUART_DRV_Init(INST_LPUART_1, &lpUartState0, &lpuart_0_InitConfig0)
!= STATUS_SUCCESS)
__asm("bkpt #255");
ftm_state_t ftmStateStruct;
/* Initialize FTM instance */
FTM_DRV_Init(INST_FLEXTIMER_PWM_1, &flexTimer_pwm_1_InitConfig, &ftmStateStruct);
/* Initialize FTM PWM */
FTM_DRV_InitPwm(INST_FLEXTIMER_PWM_1, &flexTimer_pwm_1_PwmConfig);
/*ADC0 and ADC1 Configuration*/
ADC_DRV_ConfigConverter(INST_ADC_CONFIG_1, &adc_config_1_ConvConfig0);
ADC_DRV_ConfigConverter(INST_ADC_CONFIG_2, &adc_config_2_ConvConfig0);
/*ADC0 and ADC1 Auto Calibration*/
ADC_DRV_AutoCalibration(INST_ADC_CONFIG_1);
ADC_DRV_AutoCalibration(INST_ADC_CONFIG_2);
/*PDB Configuration*/
PDB_DRV_Init(INST_PDB_0,&pdb_config_1_timerConfig0);
/*ADC0 Channel Configuration*/
ADC_DRV_ConfigChan(INST_ADC_CONFIG_1, 0U, &Current_Sense_3);
ADC_DRV_ConfigChan(INST_ADC_CONFIG_1, 1U, &Voltage_Sense_2);
ADC_DRV_ConfigChan(INST_ADC_CONFIG_1, 2U, &Voltage_Sense_3);
ADC_DRV_ConfigChan(INST_ADC_CONFIG_1, 3U, &Current_Sense_2);
/*ADC1 Channel Configuration*/
ADC_DRV_ConfigChan(INST_ADC_CONFIG_2, 0U, &Current_Sense_1);
ADC_DRV_ConfigChan(INST_ADC_CONFIG_2, 1U, &Current_Sense_4);
ADC_DRV_ConfigChan(INST_ADC_CONFIG_2, 2U, &Voltage_Sense_1);
ADC_DRV_ConfigChan(INST_ADC_CONFIG_2, 3U, &Voltage_Sense_4);
/*Check if the Interrupt value is ok*/
DEV_ASSERT(calculateIntValue(&pdb_config_1_timerConfig0, TIMEOUT_US, &pdbTimerVal) == true);
/*Pre-Trigger Configuration for ADC0 (CH0 of the PDB)*/
PDB_DRV_ConfigAdcPreTrigger(INST_PDB_0,0,&pdb_config_1_adc0TrigConfig0);
PDB_DRV_ConfigAdcPreTrigger(INST_PDB_0,0,&pdb_config_1_adc0TrigConfig1);
PDB_DRV_ConfigAdcPreTrigger(INST_PDB_0,0,&pdb_config_1_adc0TrigConfig2);
PDB_DRV_ConfigAdcPreTrigger(INST_PDB_0,0,&pdb_config_1_adc0TrigConfig3);
/*Pre-Trigger Configuration for ADC1 (CH1 of the PDB)*/
PDB_DRV_ConfigAdcPreTrigger(INST_PDB_0,1,&pdb_config_1_adc1TrigConfig0);
PDB_DRV_ConfigAdcPreTrigger(INST_PDB_0,1,&pdb_config_1_adc1TrigConfig1);
PDB_DRV_ConfigAdcPreTrigger(INST_PDB_0,1,&pdb_config_1_adc1TrigConfig2);
PDB_DRV_ConfigAdcPreTrigger(INST_PDB_0,1,&pdb_config_1_adc1TrigConfig3);
/*set the Modulus value*/
PDB_DRV_SetTimerModulusValue(INST_PDB_0, pdbTimerVal);
/*set Pre-Trigger Delays for PDB CH0*/
PDB_DRV_SetAdcPreTriggerDelayValue(INST_PDB_0, 0, 0, 400);
PDB_DRV_SetAdcPreTriggerDelayValue(INST_PDB_0, 0, 1, 800);
PDB_DRV_SetAdcPreTriggerDelayValue(INST_PDB_0, 0, 2, 1200);
PDB_DRV_SetAdcPreTriggerDelayValue(INST_PDB_0, 0, 3, 1400);
/*set Pre-Trigger Delays for PDB CH1*/
PDB_DRV_SetAdcPreTriggerDelayValue(INST_PDB_0, 1, 0, 400);
PDB_DRV_SetAdcPreTriggerDelayValue(INST_PDB_0, 1, 1, 800);
PDB_DRV_SetAdcPreTriggerDelayValue(INST_PDB_0, 1, 2, 1200);
PDB_DRV_SetAdcPreTriggerDelayValue(INST_PDB_0, 1, 3, 1400);
INT_SYS_EnableIRQ(PDB0_IRQn);
/*set the Interrupt value*/
PDB_DRV_SetValueForTimerInterrupt(INST_PDB_0, pdbTimerVal);
print("pdbTimerVal :");
uint16ToStr(&pdbTimerVal, value, 5);
print(value);
/*Load Values into the PDB*/
PDB_DRV_LoadValuesCmd(INST_PDB_0);
/*Enable the PDB*/
PDB_DRV_Enable(INST_PDB_0);
/*enable NVIC Interrupts for ADC0*/
INT_SYS_EnableIRQ(ADC0_IRQn);
/*enable NVIC Interrupts for ADC1*/
INT_SYS_EnableIRQ(ADC1_IRQn);
/* Trigger PDB timer */
PDB_DRV_SoftTriggerCmd(INST_PDB_0);
解決済! 解決策の投稿を見る。
Hi,
Thank you for the response. Now i understand that PDB0 is for ADC0 and PDB1 is for ADC1 but i have a question : how do i synchronise them? i want the conversion on ADC0 and on ADC1 to start on the same time. if i understood correctly we should use TRGMUX and FTM. if so can you tell me to parametrise TRGMUX (in the pinout section and peripheral section of s32DS) because i barely found documentation on that.
i will attach what i did under my reply.
thank you .
if you use FTM Init Trigger as PDB trigger source then you don't need to do it, because it is a internal signal.