S32K146 - Ouput Compare - FTM issue

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32K146 - Ouput Compare - FTM issue

482 Views
arielcolombo
Contributor I

Hi,

Due to the need in the product that we are developing, we need to use the FTM in output compare to generate a control signal that generates a pulse at a certain moment, the duration of the pulse being greater than several CNT cycles, which rules out the use from TOGGLE.

Initially our proposal was to use the ELSA register to exchange between SET and CLEAR at different times to generate the signal as follows:

 

if(edge_aux == 0)
{
	FTM0->CONTROLS[1].CnSC |= FTM_CnSC_ELSA_MASK;
        //Here CNV is Reset and whats can be happend when CNT == reset CNV?
        // testing that cnv reseting is 20000 and not 0(reset??).
	FTM0->CONTROLS[1].CnV = 10000;
        FTM0->STATUS &= ~FTM_STATUS_CH1F_MASK;
}
else
{
        FTM0->CONTROLS[1].CnSC &= ~FTM_CnSC_ELSA_MASK;
        //Here CNV is Reset and whats can be happend when CNT == reset CNV?
        // testing that cnv reseting is 10000 and not 0(reset??).
	FTM0->CONTROLS[1].CnV = 20000;
	FTM0->STATUS &= ~FTM_STATUS_CH1F_MASK;
}
edge_aux = ~edge_aux;

 

In the example code, when setting ELSA, CNV will be reset as indicated in the manual. So, until CNV is reloaded with the desired value, we have the following doubts:


1- What happens with the CNV at this moment, does it go to 0? or to the value of the last match (let's experiment that it goes to the last match)?
2- Could it happen that the CNT coincides at this moment with the reset value? producing a logical change in the output channel?

How could I control the logical state of the channel output, since both the OUTMASK and the SWOCTRL only change the state of the pin but not the logical state of the channel?

Thanks, I look forward to your help.

0 Kudos
Reply
1 Reply

389 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi @arielcolombo,

I uderstand you can't use a slower FTM clock so that the pulse width is within the 65535 cycles, right?

It can be done using OUTMASK witch can work with the overflow interrupt too.

An example is in this thread:

https://community.nxp.com/t5/S32K/S32K144-FTM-Output-Compare-for-Single-Pulse/m-p/844001

 

Regards,

Daniel

0 Kudos
Reply