AnsweredAssumed Answered

K22F FTM0CH2 PWM output interfering on gpio interrupt

Question asked by Mohamed ESSADOUNI on Oct 12, 2017
Latest reply on Oct 15, 2017 by xiangjun.rong

Hi guys,
I'm using K22F to generate PWM signal to drive a simple fan and use gpio falling edge interrupt to get tachy return from this fan. 

My pin conf is:

- I use FTM0CH2 on PTC5 output (means ALT7 as IO configuration)

- I use PTD6 as an input GPIO (ALT1) to get falling edge interrut on tachy signal

My problem is:

when FM0CH2 pwm output is driven to other pin than PTC5 (say PTA5 for example) the PTD6 interrupt comes as expected on falling edge of input signal (I toggle a third signal inside isr to see on scope how often the interrupt comes)
as soon as PWM is driven on PTC5 then the interrupt looks like missing or adding edges even if input signal wave is not changed.
Any has already met an effect FTM0CH2 and other pins interrupt even if they not part of same IO port (PDx different PCx)?

Here is some parts of my code:
PWM configuration:

// Configure GPIO for FTM0_CH2 function
// Enable clock gate to FM0 module

FTM0_MOD = u16ftm_mod; // FTM0 Modulo PWM period
//FTM0_C2SC = 0x28; // No Interrupts; High True pulses on Edge Aligned PWM

// FTMx_CnSC - contains the channel-interrupt status flag control bits
FTM0_C2SC |= FTM_CnSC_ELSB_MASK; //Edge or level select
FTM0_C2SC &= ~FTM_CnSC_ELSA_MASK; //Edge or level Select
FTM0_C2SC |= FTM_CnSC_MSB_MASK; //Channel Mode select

FTM0_C2V = u16ftm_cnt; // duty_cyle_percent% pulse width
FTM0_SC = (1 << 3) | (6 << 0); // Edge Aligned PWM running from BUSCLK / 64


GPIO interrupt setup:

// Enable gpio functionality for given pin, react on falling edge
if(lwgpio_int_init(&Gpio_FAN_TACHY, LWGPIO_INT_MODE_FALLING)) {
// Install the interrupt directly to the vector table in the processor
if(_int_install_isr(lwgpio_int_get_vector(&Gpio_FAN_TACHY), fan_tachy_isr, NULL)) {
// Set the interrupt level, and unmask the interrupt in interrupt controller
if(MQX_OK == _bsp_int_init(lwgpio_int_get_vector(&Gpio_FAN_TACHY), 1, 0, TRUE)) {
// Enable interrupt on GPIO peripheral module
lwgpio_int_enable(&Gpio_FAN_TACHY, TRUE);


Thanks for your help