Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gpioSetISRFunc error -123 #613

Open
TMagerat opened this issue Aug 5, 2024 · 2 comments
Open

gpioSetISRFunc error -123 #613

TMagerat opened this issue Aug 5, 2024 · 2 comments

Comments

@TMagerat
Copy link

TMagerat commented Aug 5, 2024

Hello

I'm struggling with the function
gpioSetISRFunc
I always have a bad init error -123
I tried to find some solution by disabling the W-1 interface but it does not work

This is my config.txt

I need this function because I have 2 different square signals on my PIN BCM 17 and 27 that represent the speed of 2 different rotors
I want that each time a RISING_EDGE is occuring it computes the times between the last and the current rising_edge

I tried to do

sudo -s
cd /sys/class/gpio/
echo 17 > export 
cd gpio17
echo in > direction 
echo both > edge 
cd /sys/class/gpio/
echo 17 > unexport 

as mentionned here #97 fivdi/pigpio#97

but sadly after the line

echo 17 > export 

I have an invalid argument error
My code is something like this :

void rotor1_interrupt(int gpio, int level, uint32_t tick) {
    static uint32_t last_tick = 0;
    uint32_t diff_tick;

    
    diff_tick = tick - last_tick;
    last_tick = tick;

    if (diff_tick > 0) {
        rotor1_speed = 1.0 / ((double) diff_tick / 1000000.0);
        clock_gettime(CLOCK_MONOTONIC, &speed1);
        time1 = (speed1.tv_sec - start.tv_sec) + (speed1.tv_nsec - start.tv_nsec) / 1.0e9;
    }
    rotor1_speed_buffer[rotor1_data_index] = rotor1_speed;
    time1_buffer[rotor1_data_index] = time1;
    speed_order_buffer[rotor1_data_index]=speed_order;
    rotor1_data_index++;


    update_pwm_flag_rotor1 = 1; // Indicate that rotor 1s speed has been updated
    
}
...
int main(int argc, char **argv) {
    ...
    if (gpioInitialise() < 0) {
        fprintf(stderr, "Pigpio initialization failed\n");
        return 1;
    }
    gpioSetMode(ROTOR1_PIN, PI_INPUT);
    gpioSetMode(ROTOR2_PIN, PI_INPUT);
    gpioSetMode(PWM_PIN, PI_OUTPUT);

    gpioSetISRFunc(ROTOR1_PIN, RISING_EDGE, 0, rotor1_interrupt);
    gpioSetISRFunc(ROTOR2_PIN, RISING_EDGE, 0, rotor2_interrupt);
    ...
    }

It fails at the first gpioSetISRFunc

Thanks in advance

Tom

@595NoPower
Copy link

I want to use GPIO21 as interrupt pin and encounter the exactly same problem

After trying "cat /sys/kernel/debug/gpio", I got

gpiochip0: GPIOs 512-565, parent: platform/3f200000.gpio, pinctrl-bcm2835:`
gpio-512 (ID_SDA              )
gpio-513 (ID_SCL              )
gpio-514 (GPIO2               )
gpio-515 (GPIO3               )
...
gpio-533 (GPIO21              )
...
gpio-565 (SD_DATA3_R          )
...

and then I tried the following commands
echo 533 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio533/direction
echo 1 > /sys/class/gpio/gpio533/value

GPIO21 actually output high.

So it seems to use GPIO 512-565 instead of 0-54 in my OS which is
Linux raspberrypi 6.6.31+rpt-rpi-v7 #1 SMP Raspbian 1:6.6.31-1+rpt1 (2024-05-29) armv7l GNU/Linux

but the source code of gpioSetISRFunc uses 0-54 to export, set direction and the edge of GPIO

In this situation, I don't know how to configure interrupt with pigpio.

@gpe92
Copy link

gpe92 commented Nov 2, 2024

Hi,
I've the same problem with a code which worked fine on the same RPI with previous RPI OS version in 32 bits but no longer with current RPI OS version in 64 bits ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants