Hello , I have a problem using output compare outputs.
I would like (after a generic event) to set an output compare channel output and after that run a delayed action on this output compare channel.
The wrong code is:
...
...
FTM0->SWOCTRL = 0x1010; /*(1) Set "1" FTM0_CH4 using Software Output Control*/
FTM0->CONTROLS[4].CnSC = 0x18; /* (2) FTM0_CH4 clear on match*/
FTM0->CONTROLS[4].CnV= (FTM0->CNT + 100); /* (3) Match delayed of 100 clock cycle*/
FTM0->SWOCTRL = 0x0; /* (4) Remove Software Output Control*/
...
...
After row (1) the FTM0_CH4 goes correctly high.
In row (2) and (3) I run a delayed clear of FTM0_CH4 after 100 clock cycles.
In row (4) I remove the software output control to permit delayed clear started in row (2) and (3), but after row (4) the FTM0_CH4 channel goes low immediately whithout delay.
Thanks a lot .
Hi,
The root cause for this behavior is the synchronization of the FTM module. Please check 45.5.13.6 C(n)V and C(n+1)V register synchronization Chapter.
Basically you must configure FTM to update CnV registers immediate and to generate the software trigger.
Best regards,
Razvan