UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor amamiya_ren
Visitor
156 Views
Registered: ‎11-26-2018

Gpio interrupt: interrupt is called after button is released

Jump to solution

I connected 2 buttons to a GPIO instance and enabled interrupt. My expectation is each time one button is pushed a interrupt is called. However, the interrupt is also called when I released the button. How can I cancel the interrupt caused by button release?Here is my handler code:

void Intr_Handler(void *InstancePtr){
	int value;
	XGpio_InterruptDisable(&itr,XGPIO_IR_CH1_MASK);
	if ((XGpio_InterruptGetStatus(&itr) & XGPIO_IR_CH1_MASK) !=
			XGPIO_IR_CH1_MASK) {
				return;
			}
	value = XGpio_DiscreteRead(&itr,1) - 1;
	xil_printf("Interrupt valid, Button %d is pressed\r\n",value);
	(void) XGpio_InterruptClear(&itr,XGPIO_IR_CH1_MASK);
	XGpio_InterruptEnable(&itr,XGPIO_IR_CH1_MASK);
	XTime_GetTime(&itr_start);
}
0 Kudos
1 Solution

Accepted Solutions
Visitor amamiya_ren
Visitor
89 Views
Registered: ‎11-26-2018

Re: Gpio interrupt: interrupt is called after button is released

Jump to solution

@abhinayp Thank you! I have figured it out a couple of days ago: The Gpio interrupt send a pulse when the input changes. When the button is released, the input change from 1 to 0, and an interrupt is called. I solve this by removing Gpio interrupt and connecting the button to IRT_F2P directly. 

0 Kudos
2 Replies
Highlighted
Xilinx Employee
Xilinx Employee
99 Views
Registered: ‎07-12-2018

Re: Gpio interrupt: interrupt is called after button is released

Jump to solution

Hi @amamiya_ren,

1) Enter the main loop

2) User pushes down the button - this makes the program enter another loop that will run the program. Once the program has finished, break; out of the loop back to the main where we wait for the button to be pushed again.

Best Regards
Abhinay PS
------------------------------------------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give kudos to a post which you think is helpful and reply oriented.
-------------------------------------------------------------------------------------------------------------------------------

Visitor amamiya_ren
Visitor
90 Views
Registered: ‎11-26-2018

Re: Gpio interrupt: interrupt is called after button is released

Jump to solution

@abhinayp Thank you! I have figured it out a couple of days ago: The Gpio interrupt send a pulse when the input changes. When the button is released, the input change from 1 to 0, and an interrupt is called. I solve this by removing Gpio interrupt and connecting the button to IRT_F2P directly. 

0 Kudos