How to control cycles of Timer Our component from PE?

cancel
Showing results for 
Search instead for 
Did you mean: 

How to control cycles of Timer Our component from PE?

Jump to solution
379 Views
tomasmickus
Contributor II

Simple question, how could i set a function for Timer Out component ( which is PWM 50:50 generator, up to 24Mhz i think), to tick for example 10000 periods and then set flag that it done it or wait while it do it and then stop? FRDM-Kl25Z

Strange that there is no build-in function for that :smileysad:

1 Solution
139 Views
Petr_H
NXP Employee
NXP Employee

Hi,

If there would be the number of pulses up to 256, you can use the PPG_LDD component, which allows to specify the number of pulses.

Otherwise, you would need to enable interrupt and in the OnInterrupt event routine increment a software counter and after it reaches given number (e.g.10000) call the Disable method of the component to stop pulse generation.

Best regards

Petr Hradsky

Processor Expert Support Team

View solution in original post

0 Kudos
3 Replies
140 Views
Petr_H
NXP Employee
NXP Employee

Hi,

If there would be the number of pulses up to 256, you can use the PPG_LDD component, which allows to specify the number of pulses.

Otherwise, you would need to enable interrupt and in the OnInterrupt event routine increment a software counter and after it reaches given number (e.g.10000) call the Disable method of the component to stop pulse generation.

Best regards

Petr Hradsky

Processor Expert Support Team

0 Kudos
139 Views
jackblather
Senior Contributor I

I looked at the TU0_Disable() method of the TU0 PEx component....it disables the *entire* peripheral. How do I disable the output of just a selected channel? The Vybrid RM mentions an Output Mask (section 39.4.15). This would be ideal, but PEx does not provide an interface for it.

Perhaps I just need to use the FTM_PDD_WriteOutputMaskReg() macro in FTM_PDD.h? However, there is no Read version of this macro, so in order to not clobber the existing bits, I'll have to call FTM_OUTMASK_REG() instead: Once for read, then OR my bits, the write it back. Is that going to work?

On Edit: I verified that this indeed works. Using the FTM_OUTMASK_REG() macro is all you need to manipulate the Output Mask of each individual channel.

0 Kudos
139 Views
Petr_H
NXP Employee
NXP Employee

Hi,

Your approach is perfectly ok, however, a simpler solution can be using the method SelectOutputAction of the TimerUnit_LDD coponent (I suppose you are using it).

If you use OUTPUT_NONE option there, no output is performed for a channel specified by the ChannelIdx parameter.

Best regards

Petr Hradsky

Processor Expert Support Team