K22F FTM0CH2 PWM output interfering on gpio interrupt

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

K22F FTM0CH2 PWM output interfering on gpio interrupt

658 Views
emoha
Contributor I

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)
BUT
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
PORT_PCR_REG(PORTC_BASE_PTR, 5) = PORT_PCR_MUX(ALT7) | PORT_PCR_PE_MASK | PORT_PCR_PS_MASK;
// Enable clock gate to FM0 module
SIM_SCGC6 |= SIM_SCGC6_FTM0_MASK;

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:

PORT_PCR_REG(PORTD_BASE_PTR, 6) = PORT_PCR_MUX(0x01) | PORT_PCR_PE_MASK | PORT_PCR_PS_MASK;
// 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

Tags (4)
0 Kudos
1 Reply

469 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Mohamed,

I have checked the signal assignment of K22, the PTC5 and PTD6 are independent signals. Pls check if the PTC5 and PTD6 are connected on your PCB board unexpectedly?

BR

Xiangjun Rong

0 Kudos