Hello,
Please, I need help with a new project....
I am working on new hardware based on the RT1024 EVK platform.
We need to count the variations of an external digital signal and generate an interrupt based on a certain value of this counter.
I have been looking at the QTMR options but I have not found an example that helps us understand how to configure QTMR to perform this function.
My questions are:
- How do I configure QTMR to work as a comparator?
- How do I load a value into QTMR so that it can be compared with the count of variations in the external signal?
- How do I configure the interrupt in QTMR to be generated when the count value of the variations in the external signal is equal to the defined value?
Could someone help me with my questions?
Hello mayliu,
Thank you very much for the answers...
I apologize for the insistence on the questions...
We need to compare or modify the external signal count register. How can we do this?
We also need to generate an interrupt when the external signal count register reaches the same value as the comparison register. Do you have any example with this application?
Hi @JoaoBorba ,
Thank you for your updated information.
I suggest you refer to the SDK demo routine “evkmimxrt1020_qtmr_inputcapture_outputpwm”.
I think you want the RT1020 to output a PWM signal, and input capture an external signal.
output a PWM signal: Please refer to the routine code below. You can set the signal frequency and duty cycle.
Input capture an external signal:
I recommend the input capture implementation as follows:
1: First, set the trigger mode for the input capture signal(RisingEdge, FallingEdge, RisingAndFallingEdge);
2: When the edge of the external signal changes, QTMR triggers a capture interrupt. At this time, you can read Timer Channel Capture Register(CAPT).
3: Convert CAPT to time, which is the time between you set the trigger edge of the external signal, compare it to your preset time, and handle the logic you want to implement.
Below is the example code, I have taken a screenshot for your understanding.
ps: The CAPT register can also be read in IRQ handler, but logical processing is best not implemented in IRQ handler.
Wish it helps you.
If you still have question about it, please kindly let me know.
Best Regards
mayliu
Hi @JoaoBorba ,
Thank you for your interest in the NXP MIMXRT product, I would like to provide service for you.
My questions are:
- How do I configure QTMR to work as a comparator?
Answer: Please import SDK demo “qtmr_inputcapture_outputpwm”, and refer to the example code.
- How do I load a value into QTMR so that it can be compared with the count of variations in the external signal?
Answer: This question is related to QTIMER’s clock setting.
Please refer to question1, SDK demo “qtmr_inputcapture_outputpwm”
- How do I configure the interrupt in QTMR to be generated when the count value of the variations in the external signal is equal to the defined value?
Answer: Please refer to question1, SDK demo “qtmr_inputcapture_outputpwm”, This Demo describes how to configure interrupts.
Wish it helps you.
If you still have question about it, please kindly let me know.
Best Regards
mayliu