KW24 Thread + FTM PWM

cancel
Showing results for 
Search instead for 
Did you mean: 

KW24 Thread + FTM PWM

567 Views
fabricetocci
Contributor III

Hi,

We use KW24 to build our thread solution.

We have to drive a power LED, and we have selected PTD4 configured as FTM0 channel 4.

The LED works fine but timers are broken!!

What is the mistake?

Can we drive an LED with a PWM signal on a KW24 Thread end_device?

Thank you for your support.

Best regards

Fabrice.

Labels (1)
Tags (3)
0 Kudos
3 Replies

381 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello, 

 

Sorry for the late response, let me see if I get what you are describing. 

 

By saying the timers are broken are you not getting the desired frequency? Or the LED do not change its state when configured with a timer?

 

Also, as an additional question to help me understand the problem you are facing, are you using low power? The end device demo by default goes to sleep as it is configured in low power mode. Did you disable it ?

Regards, 

Estephania

0 Kudos

381 Views
fabricetocci
Contributor III

Hi Estephania,

Thank yoiu for answering to my query.

Let me give you some more details about the issue.

My thread project is based on Kinetis_thread_1.00 code base.

I have cloned router_eligible_device and end device projects for TWR_KW24 HW

For the lab tests we have disabled low power modes (

#define gLpmIncluded_d 0)

We need to drive a power LED with a PWM signal.

We have assigned PTD4 used in alternate_4 fot FTM0_channel4 to get the PWM signal.

    kGpioTorcheDrive = GPIO_MAKE_PIN(GPIOD_IDX, 4U),

            /* Affects PORTD_PCR4 register Torche_Drive FTM0_CH4 */
            PORT_HAL_SetMuxMode(PORTD,4u,kPortMuxAlt4);

Basically, we call fsl_FTM_driver functions..

We added a function to initialize FTM into App_init.c,

here is the code :

void Torche_Init

(

void

)

{

#if IWATT4YOU_EVB1 // FTM0 Channel 4

ftm_status_t Status= kStatusFtmError;

// Configure FTM Pins

configure_ftm_pins(BOARD_FTM_INSTANCE);

// Initialize FTM module,

// configure for software trigger.

FLib_MemSet(&ftmInfo, 0, sizeof(ftmInfo));

ftmInfo.syncMethod = kFtmUseSoftwareTrig;

Status = FTM_DRV_Init(BOARD_FTM_INSTANCE, &ftmInfo);

FTM_DRV_SetClock(BOARD_FTM_INSTANCE, kClock_source_FTM_SystemClk, kFtmDividedBy1);

ftmParam.uDutyCyclePercent =Duty_Cycle_Min;

// Start PWM mode with updated duty cycle.

Status = FTM_DRV_PwmStart(BOARD_FTM_INSTANCE, &ftmParam, BOARD_FTM_CHANNEL);

// Software trigger to update registers.

FTM_HAL_SetSoftwareTriggerCmd(g_ftmBase[BOARD_FTM_INSTANCE], true);

// Delay 50ms to see the change

OSA_TimeDelay(50u);

We call

#endif // #if IWATT4YOU_EVB1

}

To change the LED light level we call the following function :

void Torche_Drive(uint8_t Duty_Cycle)

{

FTM_DRV_PwmStop(BOARD_FTM_INSTANCE, &ftmParam, BOARD_FTM_CHANNEL);

ftmParam.uDutyCyclePercent = Duty_Cycle;

// Start PWM mode with updated duty cycle.

FTM_DRV_PwmStart(BOARD_FTM_INSTANCE, &ftmParam, BOARD_FTM_CHANNEL);

// Software trigger to update registers.

FTM_HAL_SetSoftwareTriggerCmd(g_ftmBase[BOARD_FTM_INSTANCE], true);

}

Timers frequency change as soon as we call FTM_DRV_Init(BOARD_FTM_INSTANCE, &ftmInfo);

I hope, this will help you understanding the route cause of my problem.

Regards.

Fabrice.

0 Kudos

381 Views
fabricetocci
Contributor III
Dear Estephania,

The ticket can be closed.
I managed to have Timers and FTM0_channel4 working properly.
I just had to write in FTM0_C4V register to load the required duty cycle.

Thank you very mutch for your support.
Best regards.

Fabrice Tocci

0 Kudos