S32K144 2 ADC with PDB Trigger

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

S32K144 2 ADC with PDB Trigger

Jump to solution
6,504 Views
snow3847
Contributor II

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. 

void print(const char *sourceStr)
{
    uint32_t bytesRemaining;
 
    /* Send data via LPUART */
    LPUART_DRV_SendData(INST_LPUART_1, (uint8_t *) sourceStr, strlen(sourceStr));
   // LPUART_DRV_SendDataPolling(INST_LPUART_1, (uint8_t *) sourceStr, strlen(sourceStr));
    /* Wait for transmission to be successful */
    while (LPUART_DRV_GetTransmitStatus(INST_LPUART_1, &bytesRemaining)
            != STATUS_SUCCESS)
    {
    }
}
 
/* The IRQ handler uses the default IRQ handler weak symbol defined in startup (.S) file */
 
void PDB0_IRQHandler(void)
{
  /* Clear PDB instance Interrupt flag */
  PDB_DRV_ClearTimerIntFlag(INST_PDB_0);
 
  print("Timer restarting");
}
 
 
void ADC0_IRQHandler(void)
{
  /* Clear PDB instance Interrupt flag */
  PDB_DRV_ClearTimerIntFlag(INST_PDB_0);
 
  if(ADC_DRV_GetConvCompleteFlag(INST_ADC_CONFIG_1, 3)){
 
  ADC_DRV_GetChanResult(INST_ADC_CONFIG_1,0U, &res[0]);
  ADC_DRV_GetChanResult(INST_ADC_CONFIG_1,1U, &res[1]);
  ADC_DRV_GetChanResult(INST_ADC_CONFIG_1,2U, &res[2]);
  ADC_DRV_GetChanResult(INST_ADC_CONFIG_1,3U, &res[3]);
 
  adcConvDone = true;
  inc++;
 
  for(int i = 0; i<4 ; i++){
      print("ADC 0 results are :");
    uint16ToStr(&res[i], msg[i], 5);
    print(msg[i]);
  }
 
  }
  else counter++;
}
void ADC1_IRQHandler (void){
 
// /* Clear PDB instance Interrupt flag */
  PDB_DRV_ClearTimerIntFlag(INST_PDB_0);
 
if(ADC_DRV_GetConvCompleteFlag(INST_ADC_CONFIG_2, 3)){
 
  ADC_DRV_GetChanResult(INST_ADC_CONFIG_2,0U, &res1[0]);
  ADC_DRV_GetChanResult(INST_ADC_CONFIG_2,1U, &res1[1]);
  ADC_DRV_GetChanResult(INST_ADC_CONFIG_2,2U, &res1[2]);
  ADC_DRV_GetChanResult(INST_ADC_CONFIG_2,3U, &res1[3]);
 
  for(int j = 0; j<4 ; j++){
        print("ADC 1 results are :");
      uint16ToStr(&res1[j], msg1[j], 5);
      print(msg1[j]);
  }
  }
}
bool calculateIntValue(const pdb_timer_config_t * const pdbConfig, const uint32_t uSec, uint16_t * const intVal)
{
    /* Local variables used to store different parameters
     * such as frequency and prescalers
     */
    uint32_t    intVal_l            = 0;
    uint8_t     pdbPrescaler        = (1 << pdbConfig->clkPreDiv);
    uint8_t     pdbPrescalerMult    = 0;
    uint32_t    pdbFrequency;
 
    bool resultValid = false;
 
    /* Get the Prescaler Multiplier from the configuration structure */
    switch (pdbConfig->clkPreMultFactor)
    {
        case PDB_CLK_PREMULT_FACT_AS_1:
            pdbPrescalerMult    =   1U;
            break;
        case PDB_CLK_PREMULT_FACT_AS_10:
            pdbPrescalerMult    =   10U;
            break;
        case PDB_CLK_PREMULT_FACT_AS_20:
            pdbPrescalerMult    =   20U;
            break;
        case PDB_CLK_PREMULT_FACT_AS_40:
            pdbPrescalerMult    =   40U;
            break;
        default:
            /* Defaulting the multiplier to 1 to avoid dividing by 0*/
            pdbPrescalerMult    =   1U;
            break;
    }
 
    /* Get the frequency of the PDB clock source and scale it
     * so that the result will be in microseconds
     */
    CLOCK_SYS_GetFreq(CORE_CLK, &pdbFrequency);
    pdbFrequency /= 1000000;
 
    /* Calculate the interrupt value for the prescaler, multiplier, frequency
     * configured and time needed.
     */
    intVal_l = (pdbFrequency * uSec) / (pdbPrescaler * pdbPrescalerMult );
 
    /* Check if the value belongs to the interval */
    if((intVal_l == 0) || (intVal_l >= (1 << 16)))
    {
        resultValid = false;
        (*intVal) = 0U;
    }
    else
    {
        resultValid = true;
        (*intVal) = (uint16_t)intVal_l;
    }
 
    return resultValid;
}
 
//char msg[30];
uint16_t dutyCycle = 0U;
 
 
int main(void)
{
  status_t error;
 
  /* Configure clocks for PORT */
 
  CLOCK_SYS_Init(g_clockManConfigsArr, CLOCK_MANAGER_CONFIG_CNT,
  g_clockManCallbacksArr, CLOCK_MANAGER_CALLBACK_CNT);
  CLOCK_SYS_UpdateConfiguration(0U, CLOCK_MANAGER_POLICY_AGREEMENT);
 
  /* Set pins as GPIO */
  error = PINS_DRV_Init(NUM_OF_CONFIGURED_PINS0, g_pin_mux_InitConfigArr0);
  DEV_ASSERT(error == STATUS_SUCCESS);
 
  /* Set Output value LED_Green & LED_Red */
  PINS_DRV_SetPins(LED_Green_PORT, 1 << LED_Green_PIN);
//  //PINS_DRV_SetPins(LED_Red_PORT, 1 << LED_Red_PIN);

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);

 

 

0 Kudos
Reply
1 Solution
6,482 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@snow3847

Senlent_0-1716964394322.png

Senlent_1-1716964422304.png

 

But in your code, One PDB instance to trigger two ADC instances.

Senlent_2-1716964725753.png

 

View solution in original post

0 Kudos
Reply
7 Replies
1,814 Views
rohit1749
Contributor III

I'm using PTD2 (ADC1 channe2)and PTE6(ADC1 channel 11) to read analog values.The structure defined for PDB_DRV_ConfigAdcPreTrigger API is shown below.

const pdb_adc_pretrigger_config_t pdb_1_adcTrigConfig0 = {
    .adcPreTriggerIdx = 0U,
    .preTriggerEnable = true,
    .preTriggerOutputEnable = true,
    .preTriggerBackToBackEnable = false
};
 
const pdb_adc_pretrigger_config_t pdb_1_adcTrigConfig1 = {
    .adcPreTriggerIdx = 3U,
    .preTriggerEnable = true,
    .preTriggerOutputEnable = true,
    .preTriggerBackToBackEnable = true
};
 
const adc_chan_config_t adConv1_ChnConfig0 = {
  .interruptEnable = true,
  .channel = ADC_INPUTCHAN_EXT2
};
 
 
const adc_converter_config_t adConv1_ConvConfig0 = {
.clockDivide = ADC_CLK_DIVIDE_1,
.sampleTime = 12U,
.resolution = ADC_RESOLUTION_12BIT,
.inputClock = ADC_CLK_ALT_1,
.trigger = ADC_TRIGGER_HARDWARE,
.pretriggerSel = ADC_PRETRIGGER_SEL_PDB,
.triggerSel = ADC_TRIGGER_SEL_PDB,
  .dmaEnable = false,
  .voltageRef = ADC_VOLTAGEREF_VREF,
  .continuousConvEnable = true,
  .supplyMonitoringEnable = false
};
 
const adc_chan_config_t adConv1_ChnConfig1 = {
  .interruptEnable = true,
  .channel = ADC_INPUTCHAN_EXT11
};

 

 I'm not able read the analog value from PTE6 pin. Please let me know where I'm going wrong.

I have attached the codebase below.

0 Kudos
Reply
6,462 Views
snow3847
Contributor II

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 .

0 Kudos
Reply
6,458 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@snow3847

For FTM,you can use FTM init as Trigger source.

For example:

Enable FTM init trigger:

Senlent_1-1716967522942.png

Senlent_2-1716967567114.png

 

Tags (1)
0 Kudos
Reply
5,009 Views
Ben_Lee
Contributor I

hi,I Have a problem, What is TrgmuxOut2? I can't understand what is TrgmuxOut2 as Trigger object?

Tags (1)
0 Kudos
Reply
6,455 Views
snow3847
Contributor II
do i need to map the TRGMUX also in the pinout section?
0 Kudos
Reply
6,452 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@snow3847

if you use FTM Init Trigger as PDB trigger source then you don't need to do it, because it is a internal signal.

0 Kudos
Reply
6,483 Views
Senlent
NXP TechSupport
NXP TechSupport

Hi@snow3847

Senlent_0-1716964394322.png

Senlent_1-1716964422304.png

 

But in your code, One PDB instance to trigger two ADC instances.

Senlent_2-1716964725753.png

 

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-1876025%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ES32K144%202%20ADC%20with%20PDB%20Trigger%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1876025%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EI%20am%20trying%20to%20sample%202%20ADCs%20with%204%20Channels%20each%20with%201%20PDB%20module.%20i%20am%20trying%20to%20sample%20both%20ADCs%20continuously%20and%20send%20an%20interrupt%20on%20when%20the%204th%20Conversion%20is%20done%20(for%20each%20ADC)%20then%20write%20it%20to%20my%20terminal.%20I%20have%20multiple%20questions%3A%3C%2FP%3E%3CP%3E1.%20it%20samples%20only%20ADC0%20one%20time%20and%20stops%20(ADC1%20is%20not%20sampled%20at%20all%20and%20ADC0%20is%20only%20sampled%20once).%20why%3F%3C%2FP%3E%3CP%3E2.%20The%20results%20are%20not%20written%20to%20my%20terminal.%20i%20programmed%20a%20print%20function%20in%20the%20ADC%20handler.%20why%3F%3C%2FP%3E%3CP%3EPS%3A%20i%20tried%20the%20continous%20mode%20for%20the%20pdb%20and%20the%20back%20to%20back%20mode%20for%20the%20pretriggers.%26nbsp%3B%3C%2FP%3E%3CDIV%3Evoid%20print(const%20char%20*sourceStr)%3C%2FDIV%3E%3CDIV%3E%7B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20uint32_t%20bytesRemaining%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%2F*%20Send%20data%20via%20LPUART%20*%2F%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20LPUART_DRV_SendData(INST_LPUART_1%2C%20(uint8_t%20*)%20sourceStr%2C%20strlen(sourceStr))%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%2F%2F%20LPUART_DRV_SendDataPolling(INST_LPUART_1%2C%20(uint8_t%20*)%20sourceStr%2C%20strlen(sourceStr))%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%2F*%20Wait%20for%20transmission%20to%20be%20successful%20*%2F%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20while%20(LPUART_DRV_GetTransmitStatus(INST_LPUART_1%2C%20%26amp%3BbytesRemaining)%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20!%3D%20STATUS_SUCCESS)%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%7B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%7D%3C%2FDIV%3E%3CDIV%3E%7D%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%2F*%20The%20IRQ%20handler%20uses%20the%20default%20IRQ%20handler%20weak%20symbol%20defined%20in%20startup%20(.S)%20file%20*%2F%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3Evoid%20PDB0_IRQHandler(void)%3C%2FDIV%3E%3CDIV%3E%7B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%2F*%20Clear%20PDB%20instance%20Interrupt%20flag%20*%2F%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20PDB_DRV_ClearTimerIntFlag(INST_PDB_0)%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20print(%22Timer%20restarting%22)%3B%3C%2FDIV%3E%3CDIV%3E%7D%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3Evoid%20ADC0_IRQHandler(void)%3C%2FDIV%3E%3CDIV%3E%7B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%2F*%20Clear%20PDB%20instance%20Interrupt%20flag%20*%2F%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20PDB_DRV_ClearTimerIntFlag(INST_PDB_0)%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20if(ADC_DRV_GetConvCompleteFlag(INST_ADC_CONFIG_1%2C%203))%7B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%20ADC_DRV_GetChanResult(INST_ADC_CONFIG_1%2C0U%2C%20%26amp%3Bres%5B0%5D)%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%20ADC_DRV_GetChanResult(INST_ADC_CONFIG_1%2C1U%2C%20%26amp%3Bres%5B1%5D)%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%20ADC_DRV_GetChanResult(INST_ADC_CONFIG_1%2C2U%2C%20%26amp%3Bres%5B2%5D)%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%20ADC_DRV_GetChanResult(INST_ADC_CONFIG_1%2C3U%2C%20%26amp%3Bres%5B3%5D)%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%20adcConvDone%20%3D%20true%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%20inc%2B%2B%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%20for(int%20i%20%3D%200%3B%20i%26lt%3B4%20%3B%20i%2B%2B)%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20print(%22ADC%200%20results%20are%20%3A%22)%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%20%26nbsp%3B%20uint16ToStr(%26amp%3Bres%5Bi%5D%2C%20msg%5Bi%5D%2C%205)%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%20%26nbsp%3B%20print(msg%5Bi%5D)%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%20%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%7D%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20else%20counter%2B%2B%3B%3C%2FDIV%3E%3CDIV%3E%7D%3C%2FDIV%3E%3CDIV%3Evoid%20ADC1_IRQHandler%20(void)%7B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%2F%2F%20%2F*%20Clear%20PDB%20instance%20Interrupt%20flag%20*%2F%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%20PDB_DRV_ClearTimerIntFlag(INST_PDB_0)%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Eif(ADC_DRV_GetConvCompleteFlag(INST_ADC_CONFIG_2%2C%203))%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%20ADC_DRV_GetChanResult(INST_ADC_CONFIG_2%2C0U%2C%20%26amp%3Bres1%5B0%5D)%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%20ADC_DRV_GetChanResult(INST_ADC_CONFIG_2%2C1U%2C%20%26amp%3Bres1%5B1%5D)%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%20ADC_DRV_GetChanResult(INST_ADC_CONFIG_2%2C2U%2C%20%26amp%3Bres1%5B2%5D)%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%20ADC_DRV_GetChanResult(INST_ADC_CONFIG_2%2C3U%2C%20%26amp%3Bres1%5B3%5D)%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%20for(int%20j%20%3D%200%3B%20j%26lt%3B4%20%3B%20j%2B%2B)%7B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20print(%22ADC%201%20results%20are%20%3A%22)%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20uint16ToStr(%26amp%3Bres1%5Bj%5D%2C%20msg1%5Bj%5D%2C%205)%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20print(msg1%5Bj%5D)%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%20%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%20%7D%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%7D%3C%2FDIV%3E%3CDIV%3Ebool%20calculateIntValue(const%20pdb_timer_config_t%20*%20const%20pdbConfig%2C%20const%20uint32_t%20uSec%2C%20uint16_t%20*%20const%20intVal)%3C%2FDIV%3E%3CDIV%3E%7B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%2F*%20Local%20variables%20used%20to%20store%20different%20parameters%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B*%20such%20as%20frequency%20and%20prescalers%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B*%2F%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20uint32_t%26nbsp%3B%20%26nbsp%3B%20intVal_l%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%3D%200%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20uint8_t%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BpdbPrescaler%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%3D%20(1%20%26lt%3B%26lt%3B%20pdbConfig-%26gt%3BclkPreDiv)%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20uint8_t%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BpdbPrescalerMult%26nbsp%3B%20%26nbsp%3B%20%3D%200%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20uint32_t%26nbsp%3B%20%26nbsp%3B%20pdbFrequency%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20bool%20resultValid%20%3D%20false%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%2F*%20Get%20the%20Prescaler%20Multiplier%20from%20the%20configuration%20structure%20*%2F%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20switch%20(pdbConfig-%26gt%3BclkPreMultFactor)%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%7B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20case%20PDB_CLK_PREMULT_FACT_AS_1%3A%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20pdbPrescalerMult%26nbsp%3B%20%26nbsp%3B%20%3D%26nbsp%3B%20%26nbsp%3B1U%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20break%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20case%20PDB_CLK_PREMULT_FACT_AS_10%3A%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20pdbPrescalerMult%26nbsp%3B%20%26nbsp%3B%20%3D%26nbsp%3B%20%26nbsp%3B10U%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20break%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20case%20PDB_CLK_PREMULT_FACT_AS_20%3A%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20pdbPrescalerMult%26nbsp%3B%20%26nbsp%3B%20%3D%26nbsp%3B%20%26nbsp%3B20U%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20break%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20case%20PDB_CLK_PREMULT_FACT_AS_40%3A%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20pdbPrescalerMult%26nbsp%3B%20%26nbsp%3B%20%3D%26nbsp%3B%20%26nbsp%3B40U%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20break%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20default%3A%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%2F*%20Defaulting%20the%20multiplier%20to%201%20to%20avoid%20dividing%20by%200*%2F%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20pdbPrescalerMult%26nbsp%3B%20%26nbsp%3B%20%3D%26nbsp%3B%20%26nbsp%3B1U%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20break%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%7D%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%2F*%20Get%20the%20frequency%20of%20the%20PDB%20clock%20source%20and%20scale%20it%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B*%20so%20that%20the%20result%20will%20be%20in%20microseconds%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B*%2F%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20CLOCK_SYS_GetFreq(CORE_CLK%2C%20%26amp%3BpdbFrequency)%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20pdbFrequency%20%2F%3D%201000000%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%2F*%20Calculate%20the%20interrupt%20value%20for%20the%20prescaler%2C%20multiplier%2C%20frequency%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B*%20configured%20and%20time%20needed.%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B*%2F%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20intVal_l%20%3D%20(pdbFrequency%20*%20uSec)%20%2F%20(pdbPrescaler%20*%20pdbPrescalerMult%20)%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%2F*%20Check%20if%20the%20value%20belongs%20to%20the%20interval%20*%2F%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20if((intVal_l%20%3D%3D%200)%20%7C%7C%20(intVal_l%20%26gt%3B%3D%20(1%20%26lt%3B%26lt%3B%2016)))%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%7B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20resultValid%20%3D%20false%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20(*intVal)%20%3D%200U%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%7D%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20else%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%7B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20resultValid%20%3D%20true%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20(*intVal)%20%3D%20(uint16_t)intVal_l%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20%7D%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20return%20resultValid%3B%3C%2FDIV%3E%3CDIV%3E%7D%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%2F%2Fchar%20msg%5B30%5D%3B%3C%2FDIV%3E%3CDIV%3Euint16_t%20dutyCycle%20%3D%200U%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3Eint%20main(void)%3C%2FDIV%3E%3CDIV%3E%7B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20status_t%20error%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%2F*%20Configure%20clocks%20for%20PORT%20*%2F%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20CLOCK_SYS_Init(g_clockManConfigsArr%2C%20CLOCK_MANAGER_CONFIG_CNT%2C%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20g_clockManCallbacksArr%2C%20CLOCK_MANAGER_CALLBACK_CNT)%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20CLOCK_SYS_UpdateConfiguration(0U%2C%20CLOCK_MANAGER_POLICY_AGREEMENT)%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%2F*%20Set%20pins%20as%20GPIO%20*%2F%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20error%20%3D%20PINS_DRV_Init(NUM_OF_CONFIGURED_PINS0%2C%20g_pin_mux_InitConfigArr0)%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20DEV_ASSERT(error%20%3D%3D%20STATUS_SUCCESS)%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%2F*%20Set%20Output%20value%20LED_Green%20%26amp%3B%20LED_Red%20*%2F%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20PINS_DRV_SetPins(LED_Green_PORT%2C%201%20%26lt%3B%26lt%3B%20LED_Green_PIN)%3B%3C%2FDIV%3E%3CDIV%3E%2F%2F%26nbsp%3B%20%2F%2FPINS_DRV_SetPins(LED_Red_PORT%2C%201%20%26lt%3B%26lt%3B%20LED_Red_PIN)%3B%3C%2FDIV%3E%3CP%3Euint16_t%20pdbTimerVal%3B%3CBR%20%2F%3Echar%20value%5B30%5D%3B%3C%2FP%3E%3CP%3Eif%20(LPUART_DRV_Init(INST_LPUART_1%2C%20%26amp%3BlpUartState0%2C%20%26amp%3Blpuart_0_InitConfig0)%3CBR%20%2F%3E!%3D%20STATUS_SUCCESS)%3CBR%20%2F%3E__asm(%22bkpt%20%23255%22)%3B%3C%2FP%3E%3CP%3Eftm_state_t%20ftmStateStruct%3B%3C%2FP%3E%3CP%3E%2F*%20Initialize%20FTM%20instance%20*%2F%3CBR%20%2F%3EFTM_DRV_Init(INST_FLEXTIMER_PWM_1%2C%20%26amp%3BflexTimer_pwm_1_InitConfig%2C%20%26amp%3BftmStateStruct)%3B%3C%2FP%3E%3CP%3E%2F*%20Initialize%20FTM%20PWM%20*%2F%3CBR%20%2F%3EFTM_DRV_InitPwm(INST_FLEXTIMER_PWM_1%2C%20%26amp%3BflexTimer_pwm_1_PwmConfig)%3B%3C%2FP%3E%3CP%3E%2F*ADC0%20and%20ADC1%20Configuration*%2F%3CBR%20%2F%3EADC_DRV_ConfigConverter(INST_ADC_CONFIG_1%2C%20%26amp%3Badc_config_1_ConvConfig0)%3B%3CBR%20%2F%3EADC_DRV_ConfigConverter(INST_ADC_CONFIG_2%2C%20%26amp%3Badc_config_2_ConvConfig0)%3B%3C%2FP%3E%3CP%3E%2F*ADC0%20and%20ADC1%20Auto%20Calibration*%2F%3CBR%20%2F%3EADC_DRV_AutoCalibration(INST_ADC_CONFIG_1)%3B%3CBR%20%2F%3EADC_DRV_AutoCalibration(INST_ADC_CONFIG_2)%3B%3C%2FP%3E%3CP%3E%2F*PDB%20Configuration*%2F%3CBR%20%2F%3EPDB_DRV_Init(INST_PDB_0%2C%26amp%3Bpdb_config_1_timerConfig0)%3B%3C%2FP%3E%3CP%3E%2F*ADC0%20Channel%20Configuration*%2F%3CBR%20%2F%3EADC_DRV_ConfigChan(INST_ADC_CONFIG_1%2C%200U%2C%20%26amp%3BCurrent_Sense_3)%3B%3CBR%20%2F%3EADC_DRV_ConfigChan(INST_ADC_CONFIG_1%2C%201U%2C%20%26amp%3BVoltage_Sense_2)%3B%3CBR%20%2F%3EADC_DRV_ConfigChan(INST_ADC_CONFIG_1%2C%202U%2C%20%26amp%3BVoltage_Sense_3)%3B%3CBR%20%2F%3EADC_DRV_ConfigChan(INST_ADC_CONFIG_1%2C%203U%2C%20%26amp%3BCurrent_Sense_2)%3B%3C%2FP%3E%3CP%3E%2F*ADC1%20Channel%20Configuration*%2F%3CBR%20%2F%3EADC_DRV_ConfigChan(INST_ADC_CONFIG_2%2C%200U%2C%20%26amp%3BCurrent_Sense_1)%3B%3CBR%20%2F%3EADC_DRV_ConfigChan(INST_ADC_CONFIG_2%2C%201U%2C%20%26amp%3BCurrent_Sense_4)%3B%3CBR%20%2F%3EADC_DRV_ConfigChan(INST_ADC_CONFIG_2%2C%202U%2C%20%26amp%3BVoltage_Sense_1)%3B%3CBR%20%2F%3EADC_DRV_ConfigChan(INST_ADC_CONFIG_2%2C%203U%2C%20%26amp%3BVoltage_Sense_4)%3B%3C%2FP%3E%3CP%3E%2F*Check%20if%20the%20Interrupt%20value%20is%20ok*%2F%3CBR%20%2F%3EDEV_ASSERT(calculateIntValue(%26amp%3Bpdb_config_1_timerConfig0%2C%20TIMEOUT_US%2C%20%26amp%3BpdbTimerVal)%20%3D%3D%20true)%3B%3C%2FP%3E%3CP%3E%2F*Pre-Trigger%20Configuration%20for%20ADC0%20(CH0%20of%20the%20PDB)*%2F%3C%2FP%3E%3CP%3EPDB_DRV_ConfigAdcPreTrigger(INST_PDB_0%2C0%2C%26amp%3Bpdb_config_1_adc0TrigConfig0)%3B%3CBR%20%2F%3EPDB_DRV_ConfigAdcPreTrigger(INST_PDB_0%2C0%2C%26amp%3Bpdb_config_1_adc0TrigConfig1)%3B%3CBR%20%2F%3EPDB_DRV_ConfigAdcPreTrigger(INST_PDB_0%2C0%2C%26amp%3Bpdb_config_1_adc0TrigConfig2)%3B%3CBR%20%2F%3EPDB_DRV_ConfigAdcPreTrigger(INST_PDB_0%2C0%2C%26amp%3Bpdb_config_1_adc0TrigConfig3)%3B%3C%2FP%3E%3CP%3E%2F*Pre-Trigger%20Configuration%20for%20ADC1%20(CH1%20of%20the%20PDB)*%2F%3C%2FP%3E%3CP%3EPDB_DRV_ConfigAdcPreTrigger(INST_PDB_0%2C1%2C%26amp%3Bpdb_config_1_adc1TrigConfig0)%3B%3CBR%20%2F%3EPDB_DRV_ConfigAdcPreTrigger(INST_PDB_0%2C1%2C%26amp%3Bpdb_config_1_adc1TrigConfig1)%3B%3CBR%20%2F%3EPDB_DRV_ConfigAdcPreTrigger(INST_PDB_0%2C1%2C%26amp%3Bpdb_config_1_adc1TrigConfig2)%3B%3CBR%20%2F%3EPDB_DRV_ConfigAdcPreTrigger(INST_PDB_0%2C1%2C%26amp%3Bpdb_config_1_adc1TrigConfig3)%3B%3C%2FP%3E%3CP%3E%2F*set%20the%20Modulus%20value*%2F%3C%2FP%3E%3CP%3EPDB_DRV_SetTimerModulusValue(INST_PDB_0%2C%20pdbTimerVal)%3B%3C%2FP%3E%3CP%3E%2F*set%20Pre-Trigger%20Delays%20for%20PDB%20CH0*%2F%3C%2FP%3E%3CP%3EPDB_DRV_SetAdcPreTriggerDelayValue(INST_PDB_0%2C%200%2C%200%2C%20400)%3B%3CBR%20%2F%3EPDB_DRV_SetAdcPreTriggerDelayValue(INST_PDB_0%2C%200%2C%201%2C%20800)%3B%3CBR%20%2F%3EPDB_DRV_SetAdcPreTriggerDelayValue(INST_PDB_0%2C%200%2C%202%2C%201200)%3B%3CBR%20%2F%3EPDB_DRV_SetAdcPreTriggerDelayValue(INST_PDB_0%2C%200%2C%203%2C%201400)%3B%3C%2FP%3E%3CP%3E%2F*set%20Pre-Trigger%20Delays%20for%20PDB%20CH1*%2F%3C%2FP%3E%3CP%3EPDB_DRV_SetAdcPreTriggerDelayValue(INST_PDB_0%2C%201%2C%200%2C%20400)%3B%3CBR%20%2F%3EPDB_DRV_SetAdcPreTriggerDelayValue(INST_PDB_0%2C%201%2C%201%2C%20800)%3B%3CBR%20%2F%3EPDB_DRV_SetAdcPreTriggerDelayValue(INST_PDB_0%2C%201%2C%202%2C%201200)%3B%3CBR%20%2F%3EPDB_DRV_SetAdcPreTriggerDelayValue(INST_PDB_0%2C%201%2C%203%2C%201400)%3B%3C%2FP%3E%3CP%3EINT_SYS_EnableIRQ(PDB0_IRQn)%3B%3C%2FP%3E%3CP%3E%2F*set%20the%20Interrupt%20value*%2F%3CBR%20%2F%3EPDB_DRV_SetValueForTimerInterrupt(INST_PDB_0%2C%20pdbTimerVal)%3B%3C%2FP%3E%3CP%3Eprint(%22pdbTimerVal%20%3A%22)%3B%3CBR%20%2F%3Euint16ToStr(%26amp%3BpdbTimerVal%2C%20value%2C%205)%3B%3CBR%20%2F%3Eprint(value)%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%2F*Load%20Values%20into%20the%20PDB*%2F%3CBR%20%2F%3EPDB_DRV_LoadValuesCmd(INST_PDB_0)%3B%3C%2FP%3E%3CP%3E%2F*Enable%20the%20PDB*%2F%3CBR%20%2F%3EPDB_DRV_Enable(INST_PDB_0)%3B%3C%2FP%3E%3CP%3E%2F*enable%20NVIC%20Interrupts%20for%20ADC0*%2F%3CBR%20%2F%3EINT_SYS_EnableIRQ(ADC0_IRQn)%3B%3C%2FP%3E%3CP%3E%2F*enable%20NVIC%20Interrupts%20for%20ADC1*%2F%3CBR%20%2F%3EINT_SYS_EnableIRQ(ADC1_IRQn)%3B%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%2F*%20Trigger%20PDB%20timer%20*%2F%3CBR%20%2F%3EPDB_DRV_SoftTriggerCmd(INST_PDB_0)%3B%3C%2FP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2124015%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K144%202%20ADC%20with%20PDB%20Trigger%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2124015%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI'm%20using%20PTD2%20(ADC1%20channe2)and%20PTE6(ADC1%20channel%2011)%20to%20read%20analog%20values.The%20structure%20defined%20for%26nbsp%3BPDB_DRV_ConfigAdcPreTrigger%20API%20is%20shown%20below.%3C%2FP%3E%3CDIV%3Econst%20pdb_adc_pretrigger_config_t%20pdb_1_adcTrigConfig0%20%3D%20%7B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20.adcPreTriggerIdx%20%3D%200U%2C%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20.preTriggerEnable%20%3D%20true%2C%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20.preTriggerOutputEnable%20%3D%20true%2C%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20.preTriggerBackToBackEnable%20%3D%20false%3C%2FDIV%3E%3CDIV%3E%7D%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3Econst%20pdb_adc_pretrigger_config_t%20pdb_1_adcTrigConfig1%20%3D%20%7B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20.adcPreTriggerIdx%20%3D%203U%2C%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20.preTriggerEnable%20%3D%20true%2C%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20.preTriggerOutputEnable%20%3D%20true%2C%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20%26nbsp%3B%20.preTriggerBackToBackEnable%20%3D%20true%3C%2FDIV%3E%3CDIV%3E%7D%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3Econst%20adc_chan_config_t%20adConv1_ChnConfig0%20%3D%20%7B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20.interruptEnable%20%3D%20true%2C%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20.channel%20%3D%20ADC_INPUTCHAN_EXT2%3C%2FDIV%3E%3CDIV%3E%7D%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3Econst%20adc_converter_config_t%20adConv1_ConvConfig0%20%3D%20%7B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E.clockDivide%20%3D%20ADC_CLK_DIVIDE_1%2C%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E.sampleTime%20%3D%2012U%2C%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E.resolution%20%3D%20ADC_RESOLUTION_12BIT%2C%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E.inputClock%20%3D%20ADC_CLK_ALT_1%2C%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E.trigger%20%3D%20ADC_TRIGGER_HARDWARE%2C%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E.pretriggerSel%20%3D%20ADC_PRETRIGGER_SEL_PDB%2C%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E.triggerSel%20%3D%20ADC_TRIGGER_SEL_PDB%2C%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%20.dmaEnable%20%3D%20false%2C%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%20.voltageRef%20%3D%20ADC_VOLTAGEREF_VREF%2C%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%20.continuousConvEnable%20%3D%20true%2C%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%26nbsp%3B%20.supplyMonitoringEnable%20%3D%20false%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%7D%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3Econst%20adc_chan_config_t%20adConv1_ChnConfig1%20%3D%20%7B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20.interruptEnable%20%3D%20true%2C%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%20.channel%20%3D%20ADC_INPUTCHAN_EXT11%3C%2FDIV%3E%3CDIV%3E%7D%3B%3C%2FDIV%3E%3CBR%20%2F%3E%3CP%3E%26nbsp%3BI'm%20not%20able%20read%20the%20analog%20value%20from%20PTE6%20pin.%20Please%20let%20me%20know%20where%20I'm%20going%20wrong.%3C%2FP%3E%3CP%3EI%20have%20attached%20the%20codebase%20below.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2020033%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K144%202%20ADC%20with%20PDB%20Trigger%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2020033%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3Ehi%2CI%20Have%20a%20problem%2C%20What%20is%20TrgmuxOut2%3F%20I%20can't%20understand%20what%20is%26nbsp%3BTrgmuxOut2%20as%20Trigger%20object%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1877074%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K144%202%20ADC%20with%20PDB%20Trigger%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1877074%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CA%20href%3D%22mailto%3AHi%40snow3847%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EHi%40snow3847%3C%2FA%3E%3C%2FP%3E%0A%3CP%3Eif%20you%20use%20FTM%20Init%20Trigger%20as%20PDB%20trigger%20source%20then%20you%20don't%20need%20to%20do%20it%2C%20because%20it%20is%20a%20internal%20signal.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1877066%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K144%202%20ADC%20with%20PDB%20Trigger%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1877066%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3Edo%20i%20need%20to%20map%20the%20TRGMUX%20also%20in%20the%20pinout%20section%3F%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1876933%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K144%202%20ADC%20with%20PDB%20Trigger%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1876933%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CA%20href%3D%22mailto%3AHi%40snow3847%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EHi%40snow3847%3C%2FA%3E%3C%2FP%3E%0A%3CP%3EFor%20FTM%2Cyou%20can%20use%20FTM%20init%20as%20Trigger%20source.%3C%2FP%3E%0A%3CP%3EFor%20example%3A%3C%2FP%3E%0A%3CP%3EEnable%20FTM%20init%20trigger%3A%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Senlent_1-1716967522942.png%22%20style%3D%22width%3A%20291px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Senlent_1-1716967522942.png%22%20style%3D%22width%3A%20291px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F281325iC1779481ED889A2D%2Fimage-dimensions%2F291x367%3Fv%3Dv2%22%20width%3D%22291%22%20height%3D%22367%22%20role%3D%22button%22%20title%3D%22Senlent_1-1716967522942.png%22%20alt%3D%22Senlent_1-1716967522942.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Senlent_2-1716967567114.png%22%20style%3D%22width%3A%20605px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Senlent_2-1716967567114.png%22%20style%3D%22width%3A%20605px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F281326iF3A3CDFDB34656A4%2Fimage-dimensions%2F605x59%3Fv%3Dv2%22%20width%3D%22605%22%20height%3D%2259%22%20role%3D%22button%22%20title%3D%22Senlent_2-1716967567114.png%22%20alt%3D%22Senlent_2-1716967567114.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1876893%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K144%202%20ADC%20with%20PDB%20Trigger%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1876893%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3EThank%20you%20for%20the%20response.%20Now%20i%20understand%20that%20PDB0%20is%20for%20ADC0%20and%20PDB1%20is%20for%20ADC1%20but%20i%20have%20a%20question%20%3A%20how%20do%20i%20synchronise%20them%3F%20i%20want%20the%20conversion%20on%20ADC0%20and%20on%20ADC1%20to%20start%20on%20the%20same%20time.%20if%20i%20understood%20correctly%20we%20should%20use%20TRGMUX%20and%20FTM.%20if%20so%20can%20you%20tell%20me%20to%20parametrise%20TRGMUX%20(in%20the%20pinout%20section%20and%20peripheral%20section%20of%20s32DS)%20because%20i%20barely%20found%20documentation%20on%20that.%3C%2FP%3E%3CP%3Ei%20will%20attach%20what%20i%20did%20under%20my%20reply.%3C%2FP%3E%3CP%3Ethank%20you%20.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1876874%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20S32K144%202%20ADC%20with%20PDB%20Trigger%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1876874%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%3CA%20href%3D%22mailto%3AHi%40snow3847%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EHi%40snow3847%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Senlent_0-1716964394322.png%22%20style%3D%22width%3A%20688px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Senlent_0-1716964394322.png%22%20style%3D%22width%3A%20688px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F281306i23B91E1F21470FF8%2Fimage-dimensions%2F688x370%3Fv%3Dv2%22%20width%3D%22688%22%20height%3D%22370%22%20role%3D%22button%22%20title%3D%22Senlent_0-1716964394322.png%22%20alt%3D%22Senlent_0-1716964394322.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Senlent_1-1716964422304.png%22%20style%3D%22width%3A%20627px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Senlent_1-1716964422304.png%22%20style%3D%22width%3A%20627px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F281307i21CBBA641A943810%2Fimage-dimensions%2F627x621%3Fv%3Dv2%22%20width%3D%22627%22%20height%3D%22621%22%20role%3D%22button%22%20title%3D%22Senlent_1-1716964422304.png%22%20alt%3D%22Senlent_1-1716964422304.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CBR%20%2F%3E%0A%3CP%3EBut%20in%20your%20code%2C%20One%20PDB%20instance%20to%20trigger%20two%20ADC%20instances.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Senlent_2-1716964725753.png%22%20style%3D%22width%3A%20665px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22Senlent_2-1716964725753.png%22%20style%3D%22width%3A%20665px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F281311i042CA6471D97AD53%2Fimage-dimensions%2F665x544%3Fv%3Dv2%22%20width%3D%22665%22%20height%3D%22544%22%20role%3D%22button%22%20title%3D%22Senlent_2-1716964725753.png%22%20alt%3D%22Senlent_2-1716964725753.png%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E