Four PWM outputs using KSDK fsl_ftm

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

Four PWM outputs using KSDK fsl_ftm

836 Views
shauldorf
Contributor V

I need an application/demo how to use “fsl_ftm” component to generate four(4) PWM signals with the same
frequency and different Pulse-Widths (100 Hz & PW 50%, 40%, 30% and 20%).

Based on this configuration I want to use some of the methods to change Frequency and Pulse-Width
during program run time.

I’m using FRDM-K64 + KDS 3.2 , KSDK 1.3 and Processor Expert.

When I use “init_ftm” component or direct FTM register configuration (based onApplication Note AN5142)
it works successfully, but when I try to use “fsl_ftm” something is wrong and I get only single output on CH0.

Labels (1)
0 Kudos
4 Replies

612 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Shaul,

I suggest you use SDK2.0 instead of SDK1.3 based on FRDM_K64, the SDK2.0 is simpler than SDK1.3 and easy to understand.

You can download SDK2.0 from the website:

Welcome to Kinetis Expert | Kinetis Expert

Theer is an example for FTM, pls refer to the example in the directory:

C:\Freescale\SDK2.0_K64F\boards\frdmk64f\demo_apps\bubble

The example uses two two channels, if you want to use 4 channels, pls refer to the attached bubble.c

BR

Xiangjun Rong

0 Kudos

612 Views
shauldorf
Contributor V

Hello Xiangjun and Thanks,

Using “init_ftm” was quite simple.

My idea was to stay with Processor Expert and KSDK1.3.

My question is if it can be done using an “fsl_ftm” (configure four PWM’s).

Based on my earlier test this component (fsl_ftm) can’t be used to configured to capture input.

NXP solution suggested by Alice Yang (NXP) was to use “int_ftm” to do the capture configuration and

in all rest of my code I didn’t use the component methods.

I’m considering to move to KSDK 2.x but is it needed now, or to wait and see what will be included in new release that
will replace PE.  

BR

Shaul Dorf

0 Kudos

612 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Shaul,

If you develop FTM code, it is okay to use PE, SDK or writting FTM register directly as an5142, all of them can implement your application. But If you want to use SDK, I suggest you use the latest SDK2.0 instead of SDK1.3, the SDK2.0 is simpler and easy to understand.

for  capture function, you should connect the external signal to FTM_CHx pin, and use the following function to configure the FTM pin in capture mode. in the ISR of FTM, you can read the FTM_CnV register. When the predefined edge of external signal on the FTM_CHx is detected, the current FTM counter value is latched to FTM_CnV register, at the same time, an interrupt of FTM happens.

Hope it can help you.

BR

Xiangjun rong

SDK2.0 capture function:

@brief Enables capturing an input signal on the channel using the function parameters.
 *
 * When the edge specified in the captureMode argument occurs on the channel, the FTM counter is
 * captured into the CnV register. The user has to read the CnV register separately to get this
 * value. The filter function is disabled if the filterVal argument passed in is 0. The filter
 * function is available only for channels 0, 1, 2, 3.
 *
 * @param base        FTM peripheral base address
 * @param chnlNumber  The channel number
 * @param captureMode Specifies which edge to capture
 * @param filterValue Filter value, specify 0 to disable filter. Available only for channels 0-3.
 */
void FTM_SetupInputCapture(FTM_Type *base,
                           ftm_chnl_t chnlNumber,
                           ftm_input_capture_edge_t captureMode,
                           uint32_t filterValue);

0 Kudos

612 Views
shauldorf
Contributor V

Hello Xiangjun using capture was done, that’s not my question it was only example that it is not supported by fsl_ftm. It has been already implemented successfully

I want to know if four PWM’s with deferent PW can be done using fsl_ftm without using init_ftm or direct FTM registers configuration.

The question is if there is any limitation to do it using fsl_ftm only?

The problem is how to configure the fsl_ftm

In following images you can see my not working configuration.

Shaul

0 Kudos