pdb adc trigger delay problem

cancel
Showing results for 
Search instead for 
Did you mean: 

pdb adc trigger delay problem

Jump to solution
506 Views
pauvilanova
Contributor III

Hello,

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.

Captura.JPG

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;
     */
    PDB_GetDefaultConfig(&pdbConfigStruct);

    /* 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. */
    PDB_SetADCPreTriggerDelayValue(DEMO_PDB_BASE, DEMO_PDB_TRIGGER_CHANNEL0, (pdb_adc_pretrigger_t)DEMO_PDB_PRETRIGGER_CHANNEL0_MASK,200U); //PRETRIGG CH0 DELAY 200

    /* 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.

Thanks

Labels (1)
Tags (1)
0 Kudos
1 Solution
173 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Pau Vilanova,

Sorry for my late reply!

I recommend you read the AN4822: Tips and Tricks Using PDB in Motor Control Applications on Kinetis
Then you can see the "Figure 1. Internal arrangement of PDB" and "Table 1. Relation between pre-triggers and result registers".

Please check if you have modify the PreTriggerDelayValue of that corresponding ADC channel.

Internal arrangement of PDB.png

When I debug the ftm_pdb_adc16 demo, I can see the PDB0_CH0_DLY1 was wrote.
Then you may need to observe the ADC channel selected by ADC0_RB. (0x1A channel 26 Temperature sensor)

ftm_pdb_adc16.png

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

1 Reply
174 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Pau Vilanova,

Sorry for my late reply!

I recommend you read the AN4822: Tips and Tricks Using PDB in Motor Control Applications on Kinetis
Then you can see the "Figure 1. Internal arrangement of PDB" and "Table 1. Relation between pre-triggers and result registers".

Please check if you have modify the PreTriggerDelayValue of that corresponding ADC channel.

Internal arrangement of PDB.png

When I debug the ftm_pdb_adc16 demo, I can see the PDB0_CH0_DLY1 was wrote.
Then you may need to observe the ADC channel selected by ADC0_RB. (0x1A channel 26 Temperature sensor)

ftm_pdb_adc16.png

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post