stu54
Posts: 9
Joined: Tue Jul 09, 2019 10:16 pm

PI4 and GPIO not working

Thu Jul 25, 2019 5:17 pm

I am using the example C++ programming for GPIO from https://elinux.org/RPi_GPIO_Code_Samples

I read for the PI4 the BCM2708_PERI_BASE value is 0x3F000000 and for the PI2 it is 0x20000000. I tried the same
example on a PI2 and PI4 (adjusting the BCM2708_PERI_BASE for each version) and it works on the PI2 but not the PI4 (I am trying the button press code).

Has anyone had success programming the GPIO on the PI4 in C/C++? As a side note, I have tried Python on the GPIO and it
works fine on the PI4 but C/C++ does not.

Thanks.

dp11
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 23
Joined: Thu Dec 29, 2011 5:46 pm

Re: PI4 and GPIO not working

Thu Jul 25, 2019 6:36 pm

Try 0xFE000000 as the base address.

stu54
Posts: 9
Joined: Tue Jul 09, 2019 10:16 pm

Re: PI4 and GPIO not working

Thu Jul 25, 2019 10:29 pm

Thanks! That fixed it. This all came about because I posted something in another forum here about lcdproc not working on the PI 4. I made the same change in my copy of the lcdproc source and now it works, too.

Return to “C/C++”