Generate Custom pulse with S32K144

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

Generate Custom pulse with S32K144

329 Views
chandan_uv
Contributor III

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

 

chandan_uv_0-1710499215274.png

 

chandan_uv_1-1710499236002.png

 

 

0 Kudos
5 Replies

297 Views
chandan_uv
Contributor III

can you let me know how I can download all example code for S32K1xx? Also is there any better method to offload CPU?

0 Kudos

278 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @chandan_uv 

From the previous links, you can find two packages:

  • Real Time Drivers
  • Automotive SDK

Real Time Drivers can be downloaded as UpdateSite extensions and installed in S32 Design Studio with the Extensions and Updates window:

Julin_AragnM_1-1710787427148.png

 

Julin_AragnM_0-1710787184733.png

After this, a project example can be imported:

Julin_AragnM_2-1710787559500.png

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

 

0 Kudos

259 Views
chandan_uv
Contributor III

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,
}

 

 

chandan_uv_3-1710826920278.jpeg

 

chandan_uv_0-1710826688006.png

 

chandan_uv_1-1710826707563.png

 

 

chandan_uv_2-1710826756393.png

 

 

 

0 Kudos

220 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @chandan_uv,

You can look into these documents for guidance on FTM usage:

Best regards,
Julián

0 Kudos

316 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

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.

Julin_AragnM_2-1710539654659.png

 

Julin_AragnM_0-1710539511483.png

Best regards,
Julián

 

0 Kudos