S32M24x/S32K14x -> FTM: PWM Modulation Implementation

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

S32M24x/S32K14x -> FTM: PWM Modulation Implementation

S32M24x/S32K14x -> FTM: PWM Modulation Implementation

Example Description

This application demonstrates the usage FlexTimer Module in PWM Modulation Implementation mode. The application includes S32 Design Studio projects for both devices, that uses configurations for for the IP layer only (Clocks, Port_Ip_1 and Ftm_Pwm).

For more details please refer to FlexTimer Module (FTM) Usage on S32M24x and S32K14x Series.

 

Installation steps

Software installation
     S32 Design Studio for S32 Platform v.3.5
     RTD for S32K1 and S32M24x version 2.0.0 including patch P01

Hardware installation
     Supported boards:
          - S32M24xEVB-C064
          - S32K144EVK

     Connections to the scope in S32M24xEVB-C064/S32K144EVK:
          - ftm0_ch0 -> PTD15 (J21-2/J2-2)
          - ftm0_ch1  -> PTD16 (J21-1/J2-4)
          - ftm0_ch2 -> PTD0  (J60-2/J2-6)
          - ftm1_ch1   -> PTB3 (NA/J2-9) Not routable to an external pin in S32M244C_64LQFP

     Debugger in S32M24xEVB-C064/S32K144EVK
          - Use the On-board Debug Interface in J32/J7 Open SDA connector.

 

S32 Configurations Tool

     Clocks Tool

S32M244 and S32K144 features a complex clocking sourcing, distribution. To run a core of the S32M244/S32K144 as well as some MCU peripherals at maximum frequency 80 MHz in normal RUN mode, S32M244 is supplied externally by 16 MHz crystal (meanwhile S32K144 is supplied externally by 8 MHz crystal). This clock source supplies Phase-lock-loop (PLL), which circuit multiplies frequency by 20 in S32M244 (and by 40 in S32K144) and divides by 2 resulting 160 MHz frequency on output for both devices. PLL output is then divided by 2 to supply core and system (80 MHz), further divided by 2 and 4 to supply bus clock (40 MHz) and flash clock (20 MHz), respectively (See next Figure).

_Leo__0-1730328959298.png

Figure 1. S32M244 Clocks Configuration

 

     Pins Tool

In Pins Tool are selected the signals to use the FTM0 module as follows:

_Leo__7-1730329041136.png

Figure 2. S32M244 Pins Configuration

 

     Peripherals Tool

Below is the FTM0 configuration (the default configuration of the tabs that are not shown is used):

_Leo__2-1730328959208.png

Figure 3: FTM0 Hardware instance

_Leo__3-1730328959402.png

Figure 4: FTM0 Clock Configuration

_Leo__4-1730328959405.png

Figure 5: FTM0 Global Channel Configuration

_Leo__5-1730328959455.png

Figure 6: FTM0 PwmFtmCh

_Leo__8-1730329148001.png

Figure 7: FTM1 Clock Configuration

_Leo__10-1730329426274.png

Figure 8: FTM1 PwmFtmCh

 

 

Software implementation

The application software functionality perform the following instructions (see Example 1):
- Initialize Clock driver.
- Initialize Port driver
- FTM Modulation configuration
- Initialize PWM drivers
- Update periods for FTM0/1
- Update duty cycle to PWM signals

Example 1. S32M244 FTM0/1 configured by S32 SDK

int main(void)
{
/* Init clock () */
Clock_Ip_Init(&Clock_Ip_aClockConfig[0]);
	
/* Initialize all pins using the Port driver */
Port_Ci_Port_Ip_Init(NUM_OF_CONFIGURED_PINS_BOARD_InitPins, g_pin_mux_InitConfigArr_BOARD_InitPins);
	
/* FTM Modulation Implementation */
SIM_Type * simeBase = IP_SIM_BASE_PTRS;
simeBase->FTMOPT1 = SIM_FTMOPT1_FTM0_OUTSEL(7); /* 0000_0111b channels 1, 2 and 3*/
	
/* Initialize PWM drivers */
Ftm_Pwm_Ip_Init(FTM_INSTANCE_1, &Ftm_Pwm_Ip_UserCfg0);
Ftm_Pwm_Ip_Init(FTM_INSTANCE_0, &Ftm_Pwm_Ip_UserCfg0);
	
/* Set new period for for Edge-Align Pwm */
Ftm_Pwm_Ip_UpdatePwmPeriod(FTM_INSTANCE_1, 0x500, TRUE);
Ftm_Pwm_Ip_UpdatePwmPeriod(FTM_INSTANCE_0, 0x5000, TRUE);
	
/* Setup new duty cycle to PWM signals */
Ftm_Pwm_Ip_UpdatePwmChannel(FTM_INSTANCE_1, FTM1_CH_1, 0x250, 0x000, TRUE);
Ftm_Pwm_Ip_UpdatePwmChannel(FTM_INSTANCE_0, FTM_CH_0, 0x4000, 0x000, TRUE);
Ftm_Pwm_Ip_UpdatePwmChannel(FTM_INSTANCE_0, FTM_CH_1, 0x3000, 0x000, TRUE);
Ftm_Pwm_Ip_UpdatePwmChannel(FTM_INSTANCE_0, FTM_CH_2, 0x2000, 0x000, TRUE);
…
}

 

 


On the oscilloscope

Figure 9 shows ftm0_ch0 (D0), ftm0_ch1 (D1) and ftm0_ch2 (D2) signals of S32M244 on the oscilloscope. Such signals have the same period aligned in the edge, with different duty cycle and without PWM Modulation Implementation.

_Leo__9-1730329363356.png

Figure 9: Edge-align PWM (EPWM) mode without PWM Modulation Implementation (in S32M244)

Figure 10 shows same signals from Figure 9, but now with PWM Modulation.

_Leo__11-1730329496504.png

Figure 10: PWM Modulation Implementation (in S32M244)

Figure 11 shows ftm0_ch0 (D4), ftm0_ch1 (D5) and ftm0_ch2 (D6) signals of S32K144 on the oscilloscope. Such signals have the same period aligned in the edge, with different duty cycle and with PWM Modulation. Additionally this device allows to route externally the ftm1_ch1 (D7).

_Leo__12-1730329517999.png

Figure 11: PWM Modulation Implementation (in S32K144)

 

附件
无评分
版本历史
最后更新:
‎10-30-2024 04:12 PM
更新人: