_Stephan_
Posts: 2
Joined: Fri Dec 28, 2012 6:33 pm

GPIO interrupts

Fri Dec 28, 2012 6:51 pm

Hello together,

I am using rPi with the current wheezy image.
To access the GPIOs (c program) I am using the bcm2835 lib from Mike McCauley.
Today I tried the event example and found out, that the if condition never was true.

Code: Select all

    // Set RPI pin P1-15 to be an input
    bcm2835_gpio_fsel(PIN, BCM2835_GPIO_FSEL_INPT);
    //  with a pullup
    bcm2835_gpio_set_pud(PIN, BCM2835_GPIO_PUD_UP);
    // And a low detect enable
    bcm2835_gpio_len(PIN);

    while (1)
    {
		if (bcm2835_gpio_eds(PIN))
		{
			// Now clear the eds flag by setting it to 1
			bcm2835_gpio_set_eds(PIN);
			printf("low event detect for pin 15\n");
		}

		// wait a bit
		delay(500);
    }
If the GPIO was low, the program freezes.
In the forum I found a similar problem with an explanation, that this could be a CPU interrupt problem.
I have had a look at the datasheet and disbled the GPIO interrupts and now it works.

Does anybody know if the rPi needs the interrupt (gpio_int[0] #52) for any other things?
The datasheet is not really precise in the explanation of the GPIO interrupts.
Can anybody explain the interrupt function?

Thank you in advance.
Stephan

pjc123
Posts: 922
Joined: Thu Mar 29, 2012 3:37 pm
Contact: Website

Re: GPIO interrupts

Sat Dec 29, 2012 11:51 am

From Mike Mike McCauley's main page:

"CAUTION: it has been observed that when detect enables such as bcm2835_gpio_len() are used and the pin is pulled LOW it can cause temporary hangs on 2012-07-15-wheezy-raspbian and Occidentalisv01. Reason for this is not yet determined, but suspect that an interrupt handler is hitting a hard loop on those OSs. If you must use bcm2835_gpio_len() and friends, make sure you disable the pins with bcm2835_gpio_cler_len() and friends after use."

I don't need edge detection, so I use the following command to detect a low or high:

bcm2835_gpio_lev
My Raspberry Pi Project Page:

https://www.flaminghellmet.com/launch/

Return to “General discussion”