Teensy 4.1: GPIO Interrupt Priority + general interrupt question counting pulses

Status
Not open for further replies.
Hi there,
I'm a new user of the Teensy-world, so I'm excited to get started.
I have several interrupt related questions if anyone is able to point me in the right direction of:


Theoretical interrupt question:
I want to count two different types of pulses, and trigger actions once "xxx" number of each type of pulses have been observed.
Type A pulses are slow (~100kHz) but short duration (~200ns)
Type B are VERY slow (anything between 20 and 100Hz), but a much long duration (~30µs).

Most of the time they will arrive into two GPIO pins randomly, (lets say Type A into: pin 2 (EMC_04) and Type B into: pin 3 (EMC_05), but they will often arrive at exactly the same time (well, <5ns as far as my scope can measure)... how can I make sure I count both pulses and don't miss either?
My plan was to use interrupts, and give a higher priority to the faster "Type A" pulses, and a slightly less priority to the "Type B" pulses. However if I setup an ISR for each type to just "Count++", what happens when it's servicing the higher priority iterrupt and the other pulse arrives with less priority? Is it missed? Or does it sit and wait for the first higher priority interrupt to finish, and then runs the lower priority interrupt?

If the above makes sense: is it sensible to attempt to set different priorities for individual GPIO pins, or is this a fruitless exercise? If not... again any reading material / pointers to help me understand this out would be greatly appreciated.



Increasing interrupt priority on T4.1:
On a Teensy 3.2 I tested with success:
Code:
NVIC_SET_PRIORITY(IRQ_PORTA, 16)
However how is this behaviour "ported" to the T4.1 as PortA isn't a thing? I read somewhere on here that T4.1's are configured to use "fastIO", and that interrupt priority can't be changed unless they are moved back to "slowIO".
Can somepoint please point me in the direction / explain the implications of this "fast/slow" pin behaviour? How fast? How slow? Is it in any way connected to digitalWriteFast and digitalWrite?
I also read conflicting information that pins were slew rate limited by default, which would lead me to think the default mode might be "slowIO"? However this might be for older Teensys only?


All the best,
Dan
 
It's even more complex on the T4.x. Many of the pin interrupts use a single vector in the default fast mode. That means that the interrupt handler has to cycle through all the pin flags to find which one caused the interrupt. IIRC, that can take up to 140nSec. It is possible to alter the setup of a few pins on the T4.1 to have individual interrupt vectors with faster response.

I think that once a hardware interrupt is triggered, it won't be discarded until the interrupt is serviced. So if two pulses arrive at the same time, you could get one interrupt serviced, exit the handler and the second handler would be serviced. You shouldn't miss any interrupts if the code works the way it should. However, if a second interrupt occurs while the first is being serviced, you may lose information about WHEN the interrupt occurred. You wouldn't be able to get a time stamp value until the first handler finished if it was higher priority. OTOH, if the second pulse has higher priority, you could have reading of the first time stam delayed by the second interrupt. Which could all be a moot point if both interrupts are connected to a single port that has only one vector and one priority.

The difference between slow and fast port I/O is poorly documented at this time. The T4 ports are set to fast I/O at startup---which has the effect of switching Port1 to Port6, Port2 to Port7, etc. The IMX 1062 reference manual isn't very helpful in understanding this.
 
Status
Not open for further replies.
Back
Top