iMX RT1175 GPT interrupt not working

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

iMX RT1175 GPT interrupt not working

985 Views
kchan
Contributor II

I am using an MIMXRT1175 processor with GPT2 channel 1 connected to a periodic square wave signal, and GPT2 channel 2 connected to a different periodic square wave signal with a different frequency.

The RTOS is Zephyr 3.3.99.

I have set GPT2->CR to trigger an event on the rising edge for both channel 1 and channel 2.

I have set GPT2->IR to enable interrupts for channel 1 and channel 2.

I have set the source clock to the high frequency clock and have written frequency calculation code for GPT2->CNT and do verify that the source clock is running at the expected frequency.

NXP has already defined gpt2 in its devicetree for this microprocessor, and I did modify the gpt driver's ISR to check GPT2->SR for channel 1 and channel 2 flags being set.

I setup the GPT2 in main() with this:

const struct device *gpt2Dev = DEVICE_DT_GET(DT_NODELABEL(gpt2));
counter_stop(gpt2Dev);
GPT2->CR |= (GPT_CR_IM1(kGPT_InputOperation_RiseEdge) | GPT_CR_IM2(kGPT_InputOperation_RiseEdge));
GPT2->IR |= (kGPT_RollOverFlagInterruptEnable | kGPT_InputCapture1InterruptEnable | kGPT_InputCapture2InterruptEnable);
counter_start(gpt2Dev);
 

 

In counter_mcux_gpt.c, I modified mcux_gpt_isr to this:

void mcux_gpt_isr(const struct device *dev)
{
const struct mcux_gpt_config *config = dev->config;
uint32_t status;
LOG_INF("********* in mcux_gpt_isr **********************");
LOG_INF("CR: 0x%x IR: 0x%x", config->base->CR, config->base->IR);
 
status = GPT_GetStatusFlags(config->base, kGPT_InputCapture1Flag |
kGPT_InputCapture2Flag | kGPT_RollOverFlag);
GPT_ClearStatusFlags(config->base, status);
__DSB();
 
if (status & kGPT_InputCapture1Flag)
{
LOG_INF("******** got channel 1 interrupt **************");
}

if (status & kGPT_InputCapture2Flag)
{
LOG_INF("******** got channel 2 interrupt **************");
}
 
LOG_INF("==== CNT: %u ICR[0]: %u ICR[1]: %u ====", config->base->CNT,
config->base->ICR[0], config->base->ICR[1]);
}

 

I have a serial console application connected to the UART and do see other print statements.

HOWEVER, mcux_gpt_isr() is never called for a channel 1 nor a channel 2 interrupt.

Would you help me with how to get the interrupt to work please?

 

Thank you very much

 

0 Kudos
Reply
5 Replies

896 Views
kchan
Contributor II

Hi Miguel,

Thank you.  I was able to put together a sample application without Zephry RTOS and was able to see the processor trigger the GPT interrupt for events on channel 1 and on channel 2.  The GPT is set to freerun, source clock is high frequency (which we configured to 200Mhz), and defined rising edge for channel 1 and for channel 2.  The IR register is set to enable rollover, channel 1 and channel 2 events.

I am now trying to figure out how to calculate the frequency of the periodic signal coming in.  From what I can understand, when a defined event occurs on a channel (say rising edge), the processor loads the current value of register CNT into the respective ICR[].  Then if I know the source clock frequency for the GPT, then should the frequency calculation be:

GPT_source_clock_frequency / (GPT->ICR[0] - GPT->ICR[0]_prior_value)                // ignoring rollover for now

From what I am seeing in the debugger, my frequency results are wrong.  I did measure the signals coming into channel 1 and channel 2 on an oscilloscope, so that I know what frequencies to expect.

Thank you very much for your help.

0 Kudos
Reply

886 Views
Miguel04
NXP TechSupport
NXP TechSupport

Hi @kchan 

I'll review your inquiry.

Meanwhile can you help me opening a support case to follow up this case? I would like to continue the support via email.

Please refer to this community thread when you create the case.

NXP Support

Best Regards, Miguel.

0 Kudos
Reply

878 Views
kchan
Contributor II

Thank you Miguel,

 

I have just created a support case.  Please let me know if you need anything else.

0 Kudos
Reply

859 Views
Miguel04
NXP TechSupport
NXP TechSupport

Hi @kchan

Thank you for your help, we are currently working on your case.

Best Regards, Miguel.

0 Kudos
Reply

915 Views
Miguel04
NXP TechSupport
NXP TechSupport

Hi @kchan 

I'll be reviewing your code provided, meanwhile can you help me testing your configuration without the Zephyr RTOS, NXP does not provide support for Zephyr RTOS, all the questions regarding this are supported on zephyrs forums.

Getting Started Guide Zephyr

Are you using MCUXpresso or another IDE? You can find examples for output compare and timers using the GPT module.

Best Regards, Miguel.

0 Kudos
Reply