Interruptions on PSOC5

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Dear comunity:

   

I'm working with Psoc5 specifically interrupts in a single pin. When I define falling edge on input as interrupt event and I use ISR 1.50 with derived option, I realized interruption ISR_1 works on falling and rising edges. Is this normal or should work only on falling edge as I defined?

   

Thanks in advance.

0 Likes
6 Replies
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

odesus,

   

 

   

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.

0 Likes
Anonymous
Not applicable

Dear David:

   

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:

   

 

   

isr_1_Disable();

   

if(Cy_ReadPin()==0)

   

{

   

  main code of interruption

   

}

   

Cy_Pin_ClearInterrupt();

   

isr_1_Enable();

   

}// 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

0 Likes
Anonymous
Not applicable

Hi Odesus,

   

 

   

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.

0 Likes
Anonymous
Not applicable

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.

   

 

   

0 Likes
Anonymous
Not applicable

As a third case, when the PICU was configured for interrupt on "Both Edges", the output pin toggled on every edge of the input signal.

   

The oscilloscope snapshot is as shown below:

   

 

   

0 Likes
Anonymous
Not applicable

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.

0 Likes