PWM with FTM on KW24D512

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

PWM with FTM on KW24D512

831 Views
fabricetocci
Contributor III

Hi,

 

I'm building a wireless product on KW242512 IC.
I planned to drive a LED brightness with a PWM signal.

 

I started with KSDK1.3.0 / examples / twrkw24d512 / driver_examples / ftm

 

PTD4 configured as FTM0_Ch4 is used to drive LED brightness.

I have changed board.h as follow
/* The Flextimer instance/channel used for board */
#define BOARD_FTM_INSTANCE              0
#define BOARD_FTM_CHANNEL               4

 


When I run the example code nothing happens on PTD4 where I thought a PWM wave will show up.
What is wrong in my setting?
How do I need to use this example code to get a PWM signal on PTD4 pin.

 

Attached the project files

Original Attachment has been moved to: board.h.zip

Original Attachment has been moved to: main.c.zip

Original Attachment has been moved to: pin_mux.c.zip

Labels (1)
4 Replies

622 Views
fabricetocci
Contributor III

Hi Pavel,

The example code for FTM works fine with your changes!

Thank's a lot.

Regards.

Fabrice.

622 Views
chris_brown
NXP Employee
NXP Employee

Hi Fabrice,

I have to start with the obvious questions first.  What development platform are you using?  FRDM?  

Are you positive the code is running?  Are you able to see the print outs?  Are you able to step through the code and see the appropriate variables increment and decrement properly (ftmParam.uDutyCyclePercent)?

Regards,

Chris 

0 Kudos

622 Views
fabricetocci
Contributor III

Hi Chris,

Thank you for your reply Chris.

I'm using a KW24 TWR board (twrkw24d512) on IAR workbench

Yes, the code is running.
I can see the print out on the console:
"Welcome to FTM example

See the change of LED brightness"
I can step through the code and see the variable ftmParam.uDutyCyclePercent increasing and decreasing.
If I configure PTD4 PGIO, I can set and clear it and the level is correct on the scope.
If I pin mux PTD4 to alternate4 whitch is FTM0 channel4 nothing happens on PTD4 pin when ftm code example runs.

Regards,

Fabrice

0 Kudos

622 Views
pavel_krenek
NXP Employee
NXP Employee

Hi Fabrice,

I have already tested this example together with TWR-KW24 with small changes in the code:

#define BOARD_FTM_CHANNEL               4

void configure_ftm_pins(uint32_t instance)
{
switch(instance) {
case FTM0_IDX: /* FTM0 */
/* Affects PORTD_PCR6 register */
PORT_HAL_SetDriveStrengthMode(PORTD,4u,kPortLowDriveStrength);
PORT_HAL_SetMuxMode(PORTD,4u,kPortMuxAlt4);
PORT_HAL_SetSlewRateMode(PORTD,4u,kPortSlowSlewRate);
break;
default:
break;
}
}

Everything works fine, I see the PWM signal on the pin PTA4 - J19 pin 2.

Best regards,
Pavel