Generate three shifted pulses with one Flextimer

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Generate three shifted pulses with one Flextimer

1,206 次查看
tobiasoswald
Contributor I

Hello,

i would like to ask if there is a possibility of creating three pulses which are shifted against each other with only one Flextimer-Module. The MCU is a KV11.

For Example, the base period could be 30µs. Then, Pin 1 would have to be high from 0µs to 1µs, Pin 2 from 10µs to 11µs and Pin 3 from 20µs to 21µs. At 30µs a new cycle would start and Pin 1 would be set high again, for 1µs, and so on.

Is there a possibility to set this arrangement by using only one Flextimer Module, FTIM0, for example (using Combine Mode, Deadtime, etc.)?

Of course it would also be possible to set the Base period of the timer to 10µs and the CC-Value to 1µs and always toggle the active output pin at TOF, but i would rather like to have a hardware-only-solution.

The other FTIM-Modules are already used by other timing functions.

Thank you in advance,

Tobias

标签 (1)
0 项奖励
回复
2 回复数

1,072 次查看
Robin_Shen
NXP TechSupport
NXP TechSupport

Yes. It is able to creating three pulses which are shifted against each other with only one Flextimer-Module which configured as Combine Mode.

Combine mode.png
The FTM0 and FTM3 of KV11 has 6 channels.

FTM0 FTM3 KV11.png

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复

1,072 次查看
mjbcswitzerland
Specialist V

Hi Tobias

If your free FlexTimer has 6 channels you can use the combine mode to generate the required pulses.

In the uTasker project it is done like this:

    static TIMER_INTERRUPT_SETUP timer_setup = {0};                      // interrupt configuration parameters
    PWM_INTERRUPT_SETUP pwm_setup;
    pwm_setup.int_type = PWM_INTERRUPT;
    pwm_setup.int_handler = 0;
    pwm_setup.pwm_mode = (PWM_EDGE_ALIGNED);
    pwm_setup.pwm_frequency = PWM_TIMER_US_DELAY(30, 16);                // generate 30us period on PWM output
    pwm_setup.pwm_value = PWM_TIMER_US_DELAY(1, 16);                     // 1us PWM (high/low)
    pwm_setup.pwm_reference = (_TIMER_0 | 0);                            // timer module 0, channel 0          ___|-|__________________|-|______
    fnConfigureInterrupt((void *)&pwm_setup);                            // enter configuration for PWM output

    pwm_setup.pwm_mode |= (PWM_COMBINED_PHASE_SHIFT);                    // the following channel pairs are phase shifted (only possible in edge aligned mode)
    pwm_setup.pwm_phase_shift = PWM_TIMER_US_DELAY(10, 16);              // 10us delay (shift)
    pwm_setup.pwm_reference = (_TIMER_0 | 2);                            // timer module 0, channel 2          ___________|-|__________________|-|______
    fnConfigureInterrupt((void *)&pwm_setup);                            // enter configuration for PWM test
    pwm_setup.pwm_reference = (_TIMER_0 | 3);                            // timer module 0, channel 3          ___________|-|__________________|-|______
    fnConfigureInterrupt((void *)&pwm_setup);                            // enter configuration for PWM test

    pwm_setup.pwm_phase_shift = PWM_TIMER_US_DELAY(20, 16);              // 20us delay (shift)
    pwm_setup.pwm_reference = (_TIMER_0 | 4);                            // timer module 0, channel 4          __________________|-|__________________|-|______
    fnConfigureInterrupt((void *)&pwm_setup);                            // enter configuration for PWM test
    pwm_setup.pwm_reference = (_TIMER_0 | 5);                            // timer module 0, channel 5          __________________|-|__________________|-|______
    pwm_setup.pwm_mode |= (PWM_SYS_CLK | PWM_PRESCALER_16); // clock PWM timer from the system clock with /16 pre-scaler [clock is enabled here so that all prepared values are synchronised]
    fnConfigureInterrupt((void *)&pwm_setup);                            // enter configuration for PWM test


You can read the application note https://www.nxp.com/docs/en/application-note/AN5142.pdf whereby you need to understand that in this mode channels are paired (even and odd) and when working as a pair it is the first paired channel's match value that governs when the output goes high and the second one when it goes low - the two channel outputs are essentially identical (but can be subsequently complemented and delayed between each other by dead-times, which are however not of interest in your case).

Regards

Mark


Kinetis: http://www.utasker.com/kinetis.html
http://www.utasker.com/kinetis/TWR-KV10Z32.html
http://www.utasker.com/kinetis/FRDM-KV31F.html
http://www.utasker.com/kinetis/TWR-KV31F120M.html


For less questions and restrictions, and faster, cheaper developments: try uTasker for Kinetis

0 项奖励
回复