Cornetto
Posts: 6
Joined: Mon Aug 27, 2012 9:18 pm

GPIO using "bcm2835.h"

Tue Aug 28, 2012 6:13 pm

Hi,

I'm trying to use the GPIO in C/C++ but i'm facing some (probably trivial) problem. I (think I) have installed "bcm2835-1.8" according to http://www.open.com.au/mikem/bcm2835/ and I can successfully compile blink.c with

Code: Select all

gcc -o blink blink.c -l bcm2835
But when I run it "nothing" happens (a new line in the terminal is appended and the cursor moves there nothing else). I've tried adding a "printf("test");" on the first line in main but that doesn't display. Anyone got some ideas?

Thanks in advance!

ksangeelee
Posts: 192
Joined: Sun Dec 25, 2011 5:25 pm
Location: Edinburgh, UK

Re: GPIO using "bcm2835.h"

Tue Aug 28, 2012 6:32 pm

Using printf() without a newline, stdout won't flush immediately, so add fflush(stdout) afterwards to get it to display. Also, I find starting the string with '\r' (carriage-return) can be useful to stop scrolling and screen-fill, since each string will overwrite the last.

I wrote a simple utility to dump the status of the GPIO pins (link here) which might be useful for determining if the pins are configured correctly (e.g. not on ALT functions).

Cornetto
Posts: 6
Joined: Mon Aug 27, 2012 9:18 pm

Re: GPIO using "bcm2835.h"

Tue Aug 28, 2012 7:23 pm

Stupid of me to forget the newline. The application probably works then, didn't bother to actually measure the pin when I couldn't get the test message written.

Thanks for your help and the link!

pygmy_giant
Posts: 1562
Joined: Sun Mar 04, 2012 12:49 am

Re: GPIO using "bcm2835.h"

Sun Oct 07, 2012 2:22 pm

Hi

I'm having trouble installing this library

I have tried following the instructions on this page: http://www.open.com.au/mikem/bcm2835/index.html

by typing: ./configure make # as root: make check make install

but get a 'permission denied' error despite doing so as a super user :?

Any help appreciated

benyang
Posts: 3
Joined: Fri Nov 21, 2014 1:37 am

Re: GPIO using "bcm2835.h"

Sat Nov 22, 2014 11:17 am

pygmy_giant wrote:Hi

I'm having trouble installing this library

I have tried following the instructions on this page: http://www.open.com.au/mikem/bcm2835/index.html

by typing: ./configure make # as root: make check make install

but get a 'permission denied' error despite doing so as a super user :?

Any help appreciated

extract bcm2835-1.xx.tar.gz in home directory
$ sh ./configure
$ make
$ sudo make check
$ sudo make install

it works for me

brucepi
Posts: 13
Joined: Tue Feb 13, 2018 8:56 pm

Re: GPIO using "bcm2835.h"

Tue Apr 10, 2018 8:21 am

if you want to use the Python extension for libbcm2835, the correct procedure is like this:
first go and install the C library from this link and according to the instruction explained:
http://www.airspayce.com/mikem/bcm2835/
tar zxvf bcm2835-1.xx.tar.gz
cd bcm2835-1.xx
(run as root i.e su root)
./configure
make
sudo make check
sudo make install

second go to: https://pypi.python.org/pypi/PyBCM2835/0.1.0
download the package: https://pypi.python.org/packages/7b/d4/ ... 1.0.tar.gz (it may change while you are downloading so just downlaod the available version)
and according to the same site instruction take the following steps one by one:
tar xvfz bcm2835-1.22.tar.gz cd bcm2835-1.22/src
make libbcm2835.a gcc -shared bcm2835.o -o libbcm2835.so
sudo cp libbcm2835.so /usr/local/lib/
sudo cp bcm2835.h /usr/local/include/

Return to “Interfacing (DSI, CSI, I2C, etc.)”