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:
In counter_mcux_gpt.c, I modified mcux_gpt_isr to this:
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
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.
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.
Best Regards, Miguel.
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.
Are you using MCUXpresso or another IDE? You can find examples for output compare and timers using the GPT module.
Best Regards, Miguel.