Community
cancel
Showing results for 
Search instead for 
Did you mean: 
idata
Community Manager
4,657 Views

MRAA Library falling edge interrupt not proper work.

Hello everyone;

I made the one application based on switch . I want to configure switch as gpio_interrupt.

I had configure the IO4 as a interrupt for switch.

Below is my code.

# include

# include

char counter = 0;

void intrHandler(void *arg)

{

counter++;

// printf("C = %d\n",counter);

}

int main()

{

mraa_init();

mraa_gpio_context m_gpio;

m_gpio = mraa_gpio_init(4);

mraa_gpio_dir(m_gpio, MRAA_GPIO_IN);

mraa_gpio_mode(m_gpio,MRAA_GPIO_PULLUP);

mraa_gpio_isr(m_gpio, MRAA_GPIO_EDGE_FALLING, intrHandler, NULL);

sleep (20);

printf("outer_counter = %d\n",counter);

mraa_gpio_isr_exit(m_gpio);

mraa_gpio_close(m_gpio);

return 0;

}

I had check program with "MRAA_GPIO_EDGE_RISING" EDGE and its run fine and i get the 100% proper result.

but I had check program with "MRAA_GPIO_EDGE_FALLING" EDGE, it is run but result is not proper means the key press for single time and interrupt isr will call two time or random. its behaviour is random.

Please help me to solve my problem.

Thanks & Best Regards;

Nikunj Patel

0 Kudos
19 Replies
TDzei
Novice
81 Views

Dear Nikunj_Patel,

Why do you try to apply the output mode "MRAA_GPIO_PULLUP" on an input pin?

And, this works with the Arduino breakout board but not with the mini breakout board.

idata
Community Manager
81 Views

I have just use the initial pull up because my switch does not have pullup configuration.

idata
Community Manager
81 Views

Hi Nikunj_Patel,

 

 

I tested your code sending the signal of 5 V directly to the pin 4, it didn't run well because the noise was making a random behavior like you said, it happened on both edges (RISING and FALLING). So I tried to use a normal switch with a clean input signal and it worked perfectly (on both).

 

 

Personally, I would recommend you to try to use a filter to clean the signal to avoid any strange behavior. If you want to use a simple filter check this link: https://www.ikalogic.com/de-bouncing-circuits/.

 

 

I hope this information helps you.

 

 

Regards,

 

-Leonardo
idata
Community Manager
81 Views

Hi Nikunj_Patel,

 

 

Was the information useful? Did you test the interrupts using a filter? Did it work?

 

 

Remember that we are here to help you. Have a nice day.

 

 

Regards,

 

-Leonardo
idata
Community Manager
81 Views

Hello ;

We try lots but we can't set the right value of rc components.so the issue is not solve.

Can you share your schematic of switch?

Thanks & Best Regards;

Nikunj Patel

idata
Community Manager
81 Views

Hi Nikunj_Patel,

 

 

That's weird, like I told you I tested your code sending the signal of 5 V directly to the pin 4, it didn't run well because the noise was making a random behavior like you said, it happened on both edges (RISING and FALLING).

 

 

So I tried to use a switch but it didn't use a debouncing circuit, I recommended it to you because it could help you. About the switch that I used is the switch of the Grove Starter Kit ( http://wiki.seeedstudio.com/wiki/Grove_-_Starter_Kit_v3) and it worked perfectly (on both).

 

 

About the debouncing circuit, in the link that I suggested you in the last reply says that the good starting values for a general purpose de-bouncing circuit would be R1 = 10 KOhm and C1 = 100 nF ceramic capacitor.

 

 

If you still need help just let us know.

 

 

Have a nice day.

 

 

Regards,

 

-Leonardo
idata
Community Manager
81 Views

Hello Leonardo;

Thank for your help;

We have solve the de-bounce problem using the 100K(Resistor) & 1UF (Capacitor) value.

mraa library included code fine work with IO0,IO1,IO3,IO5,IO6,IO9,IO12.

but still de-bounce issue occur on IO4,IO10,IO11,IO13. (2 event occur on falling edge).

also IO2 mraa code have segmentation fault with below logs.

open("/sys/bus/iio/devices/iio:device0/name", O_RDONLY) = 4

read(4, "adc1x8s102\n", 64) = 11

close(4) = 0

time([1475494559]) = 1475494559

send(3, "<141>Oct 3 11:35:59 libmraa[116"..., 100, MSG_NOSIGNAL) = 100

stat64("/sys/class/gpio/gpio35/", 0xbff38550) = -1 ENOENT (No such file or directory)

open("/sys/class/gpio/export", O_WRONLY) = 4

write(4, "35", 2) = 2

close(4) = 0

open("/sys/class/gpio/gpio35/value", O_RDWR) = 4

lseek(4, 0, SEEK_SET) = 0

write(4, "1", 1) = -1 EPERM (Operation not permitted)

close(4) = 0

time([1475494559]) = 1475494559

send(3, "<139>Oct 3 11:35:59 libmraa[116"..., 63, MSG_NOSIGNAL) = 63

--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x14} ---

+++ killed by SIGSEGV +++

Segmentation fault

Please help us to solve the above issue.

Thanks & Best reagards;

Nikunj Patel

idata
Community Manager
81 Views

Hi Nikunj Patel,

That's weird, I tested your code with the pin 2 and I didn't get any errors (Look the photo).

As you can see in the image, I am using the pin 2 (m_gpio = mraa_gpio_init(4)). I compiled the code and I ran it without problems, and the button works perfectly.

I recommend you to try to flash the latest Edison image, and update the MRAA library to the version 1.3, and run the code again.

Let me know if you still have issues.

Regards,

 

-Leonardo
idata
Community Manager
81 Views

Hello ;

Thanks for quick reply.

We are currently use the Intel Galileo rev 2 not Edison.

I have check with mraa 1.3 library and solve the issue of IO2.

but still de-bounce issue occur on IO4,IO10,IO11,IO13. (2 event occur on falling edge).

Have you test these IO4,IO10,IO11,IO13 pins?

Thanks in advance.

Nikunj patel

idata
Community Manager
81 Views

Hi Nikunj_Patel,

 

 

We are going to move this case to the right forum (Galileo). About your case, it is weird that the debouncing circuit doesn't work in some pins. Let me do some more tests and I'll let you know when I get the results

 

 

I appreciate your patience.

 

 

Regards,

 

-Leonardo
idata
Community Manager
81 Views

Hi Nikunj_Patel,

 

 

We're still working on this, I'll let you know when I have updates of this.

 

 

I really appreciate your patience.

 

 

Regards,

 

-Leonardo
idata
Community Manager
81 Views

Hi Nikunj_Patel,

 

 

We did some tests, and we found out that all the pins are working fine. In the tests that we did we used the latest Galileo Image 201606081532, and we updated MRAA to 1.4.0.

 

 

The code that we ran is the example in the MRAA repository ( https://github.com/intel-iot-devkit/mraa/blob/master/examples/isr_pin6.c), we edited the file to use the falling edge interrupt.

 

 

We tested all the pins, and they worked without problems. So I recommend you to do the same with the example code, and let us know if you get the same results.

 

 

If you get the same results, that means that the error is in the software and it isn't in the hardware (Galileo board). In this case try to adapt your code to the example code to make sure that it works.

 

 

We will be waiting for your results.

 

 

Have a nice day.

 

 

Regards,

 

-Leonardo
idata
Community Manager
81 Views

Hello Leonardo;

We check on intel side but we cant find 201606081532 image so We check the iot-devkit-prof-dev-image-galileo-20160606.direct image from https://software.intel.com/galileo-image/latest https://software.intel.com/galileo-image/latest link and we updated MRAA to 1.4.0.

The code that we ran is the example in the MRAA repository (https://github.com/intel-iot-devkit/mraa/blob/master/examples/isr_pin6.c https://github.com/intel-iot-devkit/mraa/blob/master/examples/isr_pin6.c), we edited the file to use the falling edge interrupt and pin to 4/10/11. 

but still issue is not solved.

please tell us the your switch configuration.

Thanks in advance.

idata
Community Manager
81 Views

Hi Nikunj_Patel,

 

 

It is the same image, if you write the command: cat /etc/version you will get the number 201606081532.

 

 

About the button that I'm using, it is the button of the http://wiki.seeedstudio.com/wiki/Grove_-_Starter_Kit_v3 Grove Starter Kit, so I'm not using any external circuit, and it works perfectly.

 

 

Have a nice day.

 

 

Regards,

 

-Leonardo
idata
Community Manager
81 Views

Hello;

I have checked http://wiki.seeedstudio.com/wiki/Grove_-_Starter_Kit_v3 Grove Starter Kit switch configuration but it has pull down configuration.

can you know the result of all pins after testing with Rising edge interrupt mode ?

Thanks in advance.

idata
Community Manager
81 Views

Hi Nikunj_Patel,

 

 

We tested the three edge modes (Rising, Falling and Both) in all the pins, and they worked without problems. I'm not sure why you have this problem. It is weird.

 

 

Have you tried to debounce the input signal with software? It can be another solution that can be useful for you.

 

 

Have a nice day.

 

 

Regards,

 

-Leonardo
idata
Community Manager
81 Views

Hi Nikunj_Patel,

 

 

I was wondering if you have updates about this.

 

 

Remember that we are here to help.

 

 

Regards,

 

-Leonardo
idata
Community Manager
81 Views

Thanks for your support.

but still the issue is not solved.

Thanks for your help.

idata
Community Manager
81 Views

Hi Nikunj_Patel,

 

 

Well, that's weird. We already tested the pins and we didn't have issues.

 

 

Can you provide us any additional information that can be useful for further analysis?

 

 

Have a nice day.

 

 

Regards,

 

-Leonardo
Reply