i tested a project with interrupt on "falling edge" on the pin and "derived" on interrupt.
As per my observation, the interrupt was obtained (LED Toggle) upon falling edge. Sometimes (like 1 in 10 times), i observed that the LED toggled upon rising edge. i strongly suspect that this may be due to switch debounce.
Make sure that the resistive pull up is enabled when using falling edge as interrupt source.
i have uploaded the project.
trial_1.zip 577.2 K
Thanks for your answer. Yes I have notice this, interruption serves on falling and rising edges. In fact to avoid this I have used a
code like this:
main code of interruption
}// end of interrupt
Unfortunately interrupt WORKS on both edges, so when you stop of pressing the button and goes high considering the code above the main code of interruption will never executed if button is not pressed. That I was wondering if this is a kind of error on API's or something like that. Lets see what a cypress engineer tell us about it. Thanks
The PICU Interrupt can be set to Rising edge, Falling edge or on Both edge.
The project attached by David is configured for interrupt on Falling edge. The LED toggles on the Falling edge. Interrupt is not generated on the rising edge.
As mentioned by David, the Switch Debounce might result in the input pin going high > low > high instead of going high directly (The resistive pull up is enabled, hence the pin is pulled up by default).
This will inevitably result in the PICU interrupt getting triggered because of a high > low transition (falling edge).
In order to overcome the ambiguity introduced by the switch debounce, I tested the project by giving a square wave at the Pin input. The output pin was supposed to toggle on falling edge of the input signal.
The oscilloscope snap-shot is attached below:
Yellow waveform = Input signal to PICU
Blue waveform = Output pin toggle.
It can be seen that the output pin toggles only on the falling edge of the PICU input pin.
On similar grounds, the PICU was changed to Interrupt on "Rising Edge".
The snapshot below shows that output pin toggles on every rising edge of the input signal.
Many thanks for your answers!!
Yes, I have understood what is the matter with interruptions, specially using pushbuttons which can be very noisy. I've observed there are some registers which are related to interrupt flags like primask, xPSR,etc.
When I enter to my interruption I have notice despite use PIN_ClearInterrupt() function, the flag seems to be still activated so this interruption is served 2 times.
1.-Is there any way to read the status of this interrupt and clear the flag directly using ASM to remove this mask interrupt? 2.-Where is the address of this interrupt register to access directly? I mean to clear all possible interrupts associated to this pin.
On technical datasheets I have observed PIN_ClearInterupt() must clear all interrupts, but I don't know why in my case is not working.
Thanks in advance for all your comments.