Hello. This is Mr. Dongho Ha
I am trying FTM EPWM using KEXX_DRIVERS_V1.2.1_DEVD example.
My source code is below (using IAR Compliler)
---------------------------------------------------------------------------------------------------------------------------------
#include "common.h"
#include "gpio.h"
#include "ftm.h"
#include "sysinit.h"
#define ACT_LED_Init() GPIOA->PDDR |= GPIO_PTA7_MASK
#define ACT_LED_Toggle() GPIOA->PTOR = GPIO_PTA7_MASK
int main (void)
{
unsigned char i;
sysinit();
ACT_LED_Init();
printf("\nRunning the FTM EPWM_demo project.\n");
UART_WaitTxComplete(TERM_PORT);
// FTM2 is set as edge aligned pwm mode, high true pulse */
FTM_PWMInit(FTM2, FTM_PWMMODE_EDGEALLIGNED, FTM_PWM_HIGHTRUEPULSE);
FTM_SetFTMEnhanced(FTM2); //FTMEN enable
FTM_SetModValue(FTM2, 40000); //update MOD value, 16bit value, 1KHz
/* set clock source, start counter */
FTM_ClockSet(FTM2, FTM_CLOCK_SYSTEMCLOCK, FTM_CLOCK_PS_DIV1);
FTM_SetChannelValue(FTM2, FTM_CHANNEL_CHANNEL1, 0);
i=0;
while(1)
{
FTM_SetChannelValue(FTM2, FTM_CHANNEL_CHANNEL1, i*400);
if(i>=100)
{
i=0;
}
Delay_ms(10);
i++;
}
}
--------------------------------------------------------------------------------------------------------------------------------
I used FTM2 channel 1. (GPIO PTC1 FTM2CH1)
This example operate well. (0~100% variation for one second)
Modulation frequency : 1kHz.
But all FTM2 port output 1kHz pulse with fixed duty.
[ PTC0(FTM2CH0),PTC2(FTM2CH2),PTC3(FTM2CH3),PTB4(FTM2CH4),PTB5(FTM2CH5) ]
FTM2CH0~FTM2CH5 output 1Khz pulse regardless of GPIO setting(Input/Output).
I want to operate only PTC1(FTM2CH1) well.
And if FTM Module change , (using FTM0, FTM1) , MCU be halted.
Question1.
I want to operate only PTC1(FTM2CH1) well.
And I want to use other GPIO pins(PTC0, PTC2, PTC3, PTB4, PTB5) for input or output normaly.
Question2.
I want to use FTM0 or FTM1 EPWM well.
I tried 2days.
But I couldn't find any method.
I want help for these problems.
Thank you.