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:
* 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
/* Configure the delay interrupt. */
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.