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.