Hello everybody!
I am trying to periodically trigger the FTM using the PDB. The problem is that the FTM is only triggered once, not periodically, as suggested by this oscilloscope screenshot:
I have configured the FTM interrupt to stop the FTM after a pulse and then re-initialise it, so that it will produce another pulse when triggered by a sync signal. The first pulse in the image is caused by the initialisation of the FTM, and the second pulse is caused by the PDB triggering the FTM.
Afterwards, the PDB just simply doesn't seem to trigger the FTM anymore.
The PDB is setup using the following KSDK code:
pdb_config_t pdbConfigStruct;
PDB_GetDefaultConfig(&pdbConfigStruct);
pdbConfigStruct.triggerInputSource = kPDB_TriggerInput4;
PDB_Init(PDB0, &pdbConfigStruct);
PDB_SetModulusValue(PDB0, 1000U);
PDB_SetCounterDelayValue(PDB0, 0U);
PDB0->CH[1].C1 = PDB_C1_BB(0b00) | PDB_C1_TOS(0b00) | PDB_C1_EN(0b01); PDB_DoLoadValues(PDB0);
My current guess is that the pre-trigger lock as described in page 884 of the reference manual isn't being cleared, since I am not using the ADC, thus preventing further triggers. However, I have tried to initialise the ADC and to clear the sequence errors as described in page 5 of appnote AN4822, but all to no avail. In fact, clearing the sequence errors seemed to irrecoverably stop the PDB.
A more knowledgeable opinion is greatly appreciated.
已解决! 转到解答。
Hello Jorge Alcala,
Thank you for your time.
I am sorry for the late reply, but in the meantime I managed to find out what caused the problem. I will document the solution here for future reference.
I had the HWTRIGMODE bit of the SYNCONF register set 0, so that the FTM would clear the hardware trigger settings every time it was triggered. After the first pulse the FTM generated, it erased the hardware trigger settings, so that it could never be triggered again, hence why I only got a single pulse.
Setting the bit using:
FTM0->SYNCONF |= 1;
solved my issue.
Best regards,
Arthur Admiraal
Hi Arthur Admiraal
Could you explain how you set the FTM trigger? it was made in the interrupt?.
Also are you triggering your PDB with PIT Ch 0 Output? PDB_GetDefaultConfig function set pdbConfigStruct.enableContinuousMode = false; So it is configured in One-Shot mode, if you want your PDB operates in continues mode you need to set this option in true.
Waiting for you reply, please let me know if you have any other question.
Have a great day,
Jorge Alcala
Hello Jorge Alcala,
Thank you for your time.
I am sorry for the late reply, but in the meantime I managed to find out what caused the problem. I will document the solution here for future reference.
I had the HWTRIGMODE bit of the SYNCONF register set 0, so that the FTM would clear the hardware trigger settings every time it was triggered. After the first pulse the FTM generated, it erased the hardware trigger settings, so that it could never be triggered again, hence why I only got a single pulse.
Setting the bit using:
FTM0->SYNCONF |= 1;
solved my issue.
Best regards,
Arthur Admiraal