Hi, I need to generate custom 400khz pulse where pin output should be changed in 0.4us. I don't want to overload CPU. do u have example code which I can refer to generate the pulse using PWM with DMA or FlexIO. Which method should I choose? I need to send data stream using below protocol. Thanks
can you let me know how I can download all example code for S32K1xx? Also is there any better method to offload CPU?
Hi @chandan_uv
From the previous links, you can find two packages:
Real Time Drivers can be downloaded as UpdateSite extensions and installed in S32 Design Studio with the Extensions and Updates window:
After this, a project example can be imported:
Please refer to the HOWTO links for guides on installation, how to import the examples and how to create projects from these packages.
Best regards,
Julián
For starting, I was only running the FTM timer with periodic interrupt (following the SDK example code). My system clock is 80MHZ but unable to figure out why interrupt is occurring at 86.2 KHZ (Around). Sharing the code and registers data. any suggestions?
ftm_state_t ftm_state;
/* Global configuration of flexTimer_mc_1 InitConfig 0 */
ftm_user_config_t flexTimer_mc_1_InitConfig_0 =
{
{
true, /* Software trigger state */
false, /* Hardware trigger 1 state */
false, /* Hardware trigger 2 state */
false, /* Hardware trigger 3 state */
false, /* Max loading point state */
false, /* Min loading point state */
FTM_SYSTEM_CLOCK, /* Update mode for INVCTRL register */
FTM_SYSTEM_CLOCK, /* Update mode for SWOCTRL register */
FTM_SYSTEM_CLOCK, /* Update mode for OUTMASK register */
FTM_SYSTEM_CLOCK, /* Update mode for CNTIN register */
false, /* Automatic clear of the trigger*/
FTM_UPDATE_NOW, /* Synchronization point */
},
FTM_MODE_UP_TIMER, /* Mode of operation for FTM */
FTM_CLOCK_DIVID_BY_1, /* FTM clock prescaler */
FTM_CLOCK_SOURCE_SYSTEMCLK, /* FTM clock source */
FTM_BDM_MODE_11, /* FTM debug mode */
true, /* Interrupt state */
false /* Initialization trigger */
};
void FTM0_Ovf_Reload_IRQHandler(void)
{
PINS_DRV_TogglePins(LED1_CTRL_GPIO, (1 << LED1_CTRL_PIN));
FTM_DRV_ClearStatusFlags(0, (uint32_t)FTM_TIME_OVER_FLOW_FLAG);
}
/* Timer mode configuration for flexTimer_mc_1 TimerConfig 0 */
ftm_timer_param_t flexTimer_mc_1_TimerConfig_0 =
{
FTM_MODE_UP_TIMER, /* Counter mode */
0, /* Initial counter value */
3, //48000 /* Final counter value */
};
void run_demo_led(void){
/* Initialize FTM */
FTM_DRV_Init(0, &flexTimer_mc_1_InitConfig_0, &ftm_state);
/* Initialize counter */
FTM_DRV_InitCounter(0, &flexTimer_mc_1_TimerConfig_0);
/* Start Counter */
FTM_DRV_CounterStart(0);
while(1){
}
}
{
.clockName = FTM0_CLK,
.clkGate = true,
.clksrc=CLK_SRC_SPLL_DIV1, //CLK_SRC_SIRC_DIV1,
.frac = MULTIPLY_BY_ONE,
.divider = DIVIDE_BY_ONE,
}
Hi @chandan_uv,
You can look into these documents for guidance on FTM usage:
Best regards,
Julián
Hi @chandan_uv,
You can find examples for a PWM signal with the FTM module through the S32K1 RTD package, or the PWM examples from the SDK RTM package. Please look into the list of HOWTOs for guides on installation and how to import the examples.
Best regards,
Julián