I’m using a SC20260D and I’m trying to use pin PA5 as a GPIO digital interrupt for a temperature sensor. If I poll the pin manually, I can see the value change from high to low when the alert hits. However, when I configure the pin to interrupt on change (as in the GPIO input tutorial), the interrupt never happens.
I’ve noticed this issue on all pins that are simultaneously used as ADC pins. So, I would like to know if there is a different way to configure these ADC pins as digital interrupts, or if there is a mistake in the pinout documentation.
Have you tried it with only 1 ValueChangedEdge option? There is something in the back of my mind that I tried Rising and Falling edge and had an issue, but maybe I am mistaken. It would at least simplify it some for testing purposes.
I think we might be getting side tracked… unless I’m not understanding this correctly (which is very possible).
Again, if I poll the gpio pin using a while loop, and simply read it’s value using _tempInterruptPin.Read(), I can see the value change from high to low and vice versa. The pin is working and GHI board can successfully read it. The only issue is the intended interrupt function is not being invoked.
I appreciate all the responses! Let me know if I am still off track, thanks!
P.S. @skeller I will try doing one edge and report back
I don’t think this is part of your problem, but the above code has a sort of race condition.
I have not seen any discussion on how interrupts are handled in TinyClr, but I assume it is the similar to .Net Micro Framework.
When an interrupt occurs, your handler is not called directly. Rather, an interrupt block is created and placed on an internal queue. The associated interrupt handler is then scheduled to run on the event thread.
What this means is there is a delay between the time that the interrupt condition occurs and your handler is dispatched.
In the code snippet you showed, you are reading the current state of the input pin. But, the current state of the pin may not reflect its state when the interrupt fired.
The preferred method is to use the pin state in the GpioPinValueChangedEventArgs object passed to the interrupt. This object contains information about the pin at the time of the interrupt.
Yes, reading the state here is not correct if the state changed quickly.
I think “GpioPinValueChangedEventArgs e” has a field that tell the state caused interrupt. Or simple, just remove checking state to see if interrupt is fired.