AnsweredAssumed Answered

pdb adc trigger delay problem

Question asked by Pau Vilanova on Jul 17, 2018
Latest reply on Jul 23, 2018 by Robin_Shen


I'm working with the freedom board mkv11z and I'm trying to implement an ADC triggered with the programable delay block. This PDB is hardware triggered by every high of my flextimer0.

My problem is that the pdb triggers my adc instantenously when it recives my FTM interrupt, summarizing, that I cannot delay my delay block. Changing delay value just ignores me and keeps triggering the ADC at the same time.

I'm using the example code provided by the driver of my freedom board ftm_pdb_adc16 and changing values of delay doesn't change  the time that triggers my ADC. I tried to change my ftm to single edge (in the example was combined pwm) and just code one adc channel disabling back to back operation but even doing that PDB delay does not change.

I'm attaching a picture of the signals. the blue one is my pwm and the green one toggles when the adc is triggered by my PDB.

And thats my pdb configuration:

    pdb_config_t pdbConfigStruct;
    pdb_adc_pretrigger_config_t pdbAdcPreTriggerConfigStruct;


     * pdbConfigStruct.loadValueMode = kPDB_LoadValueImmediately;
     * pdbConfigStruct.prescalerDivider = kPDB_PrescalerDivider1;
     * pdbConfigStruct.dividerMultiplicationFactor = kPDB_DividerMultiplicationFactor1;
     * pdbConfigStruct.triggerInputSource = kPDB_TriggerSoftware;
     * pdbConfigStruct.enableContinuousMode = false;


    /* Config PDB */
    pdbConfigStruct.triggerInputSource = kPDB_TriggerInput8; //FTM0 INPUT


    PDB_Init(DEMO_PDB_BASE, &pdbConfigStruct);


    /* Configure the delay interrupt. */
    PDB_SetModulusValue(DEMO_PDB_BASE, 5000U);
    PDB_SetCounterDelayValue(DEMO_PDB_BASE, 1000U);


    pdbAdcPreTriggerConfigStruct.enableBackToBackOperationMask = 0;        //NO BACK TO BACK
    pdbAdcPreTriggerConfigStruct.enablePreTriggerMask = (DEMO_PDB_PRETRIGGER_CHANNEL0_MASK );    //ENABLE CH0
    pdbAdcPreTriggerConfigStruct.enableOutputMask =(DEMO_PDB_PRETRIGGER_CHANNEL0_MASK);            //OUTPUT CH0


    PDB_SetADCPreTriggerConfig(DEMO_PDB_BASE, DEMO_PDB_TRIGGER_CHANNEL0, &pdbAdcPreTriggerConfigStruct);


    /* Configure the ADC Pre-Trigger. */


    /* Load PDB register */
    PDB_DoLoadValues(DEMO_PDB_BASE); //LDOK = 1


All said, the documentation about pdb on kinetis which I've found on the intered is so confusing. If anyone could send me briefings or documents I'll appreciate that.