System Timer access and GPIO does not work on my PI 2

212 views
Skip to first unread message

Yanxiang Mao

unread,
Mar 29, 2015, 8:47:27 PM3/29/15
to bcm...@googlegroups.com
Here is my code:

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <bcm2835.h> 
#include <inttypes.h>

int main(int argc, char* argv[])
{
uint64_t start, end;

if(!bcm2835_init())
return 1;

// Read start time
start = bcm2835_st_read();

// Call sleep(1) 10 times decrease the error
sleep(1);

// Read end time
end = bcm2835_st_read();
// Print result
printf("time = %llu uS\n", (end-start)/(10));

bcm2835_close();
return 0;
}

The out put is 0 us.

And I have a another question, where I can find RPiGPIOPin for PI 2?

Mike McCauley

unread,
Mar 29, 2015, 9:27:49 PM3/29/15
to bcm...@googlegroups.com
What do you see on RPi 1?
> <http://www.airspayce.com/mikem/bcm2835/group__constants.html#ga63c029bd6500
> 167152db4e57736d0939> for PI 2?

--
Mike McCauley VK4AMM mi...@airspayce.com
Airspayce Pty Ltd 9 Bulbul Place Currumbin Waters QLD 4223 Australia
http://www.airspayce.com
Phone +61 7 5598-7474

Yanxiang Mao

unread,
Mar 29, 2015, 10:24:34 PM3/29/15
to bcm...@googlegroups.com
Around 1000200 us on RPi B.

在 2015年3月30日星期一 UTC+8上午9:27:49,Mike McCauley写道:

Mike McCauley

unread,
Mar 30, 2015, 12:33:49 AM3/30/15
to bcm...@googlegroups.com
And what OS and version are you using?

lanlongzhiwang

unread,
Mar 30, 2015, 1:39:26 AM3/30/15
to bcm...@googlegroups.com
On RPi 2, OS is 3.18.10-v7, bcm2835 library is 1.43. I tried 1.39 to 1.43 not even one got work.

发件人: Mike McCauley
发送时间: ‎3/‎30/‎2015 12:33 AM
收件人: bcm...@googlegroups.com
主题: Re: [bcm2835] System Timer access and GPIO does not work on my PI 2

--
You received this message because you are subscribed to a topic in the Google Groups "bcm2835" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/bcm2835/zMqZ2adlopQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to bcm2835+u...@googlegroups.com.
To post to this group, send email to bcm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bcm2835/7116637.JyIYjsznxo%40zulu.
For more options, visit https://groups.google.com/d/optout.

Mike McCauley

unread,
Mar 30, 2015, 3:31:59 AM3/30/15
to bcm...@googlegroups.com
And what distribution is that? Raspbian? What date?


On Monday, March 30, 2015 01:48:01 AM lanlongzhiwang wrote:
> On RPi 2, OS is 3.18.10-v7, bcm2835 library is 1.43. I tried 1.39 to 1.43
> not even one got work.
>
> -----原始邮件-----
> 发件人: "Mike McCauley" <mi...@airspayce.com>
> 发送时间: ‎3/‎30/‎2015 12:33 AM
> 收件人: "bcm...@googlegroups.com" <bcm...@googlegroups.com>

Mike McCauley

unread,
Mar 30, 2015, 7:43:06 AM3/30/15
to bcm...@googlegroups.com
For RPi 2 you MUST use the latest version of bcm2835 (version 1.43) AND the
latest version of the RPI software. Check whether /proc/device-tree/soc/ranges
exists on your OS. It needs to be there for bcm2835 to work on RPi2


Cheers.

On Monday, March 30, 2015 01:48:01 AM lanlongzhiwang wrote:
> On RPi 2, OS is 3.18.10-v7, bcm2835 library is 1.43. I tried 1.39 to 1.43
> not even one got work.
>
> -----原始邮件-----
> 发件人: "Mike McCauley" <mi...@airspayce.com>
> 发送时间: ‎3/‎30/‎2015 12:33 AM
> 收件人: "bcm...@googlegroups.com" <bcm...@googlegroups.com>

Yanxiang Mao

unread,
Mar 30, 2015, 7:50:10 AM3/30/15
to bcm...@googlegroups.com
2015-02-16-raspbian-wheezy

在 2015年3月30日星期一 UTC+8下午7:43:06,Mike McCauley写道:

Yanxiang Mao

unread,
Mar 30, 2015, 8:16:22 AM3/30/15
to bcm...@googlegroups.com
I dont know what wrong with my RPI 2, there is no /device-tree under /proc.


在 2015年3月30日星期一 UTC+8下午7:43:06,Mike McCauley写道:
For RPi 2 you MUST use the latest version of bcm2835 (version 1.43) AND the

Manuel Hecht

unread,
Mar 30, 2015, 11:19:40 AM3/30/15
to bcm...@googlegroups.com
Hello

I had the same problem. Here is the solution to enable device tree support. (special thanks to Mark)


sudo raspi-config
under Advanced Options - enable Device Tree
under Advanced Options - disable SPI
Reboot and it should hopefully work.


Regards
Manuel

Yanxiang Mao

unread,
Mar 30, 2015, 12:22:50 PM3/30/15
to bcm...@googlegroups.com
Thank you for help. But still does not work, I may try to reinstall my OS.

在 2015年3月30日星期一 UTC+8下午11:19:40,Manuel Hecht写道:

Mike McCauley

unread,
Mar 30, 2015, 7:07:34 PM3/30/15
to bcm...@googlegroups.com
Im quite sure you will find that if you have the latest debian, with device
tree enabled it will work:

tested here today:

pi@raspberrypi ~/bcm2835-1.43 $ gcc -o x -I src src/bcm2835.c x.c
pi@raspberrypi ~/bcm2835-1.43 $ sudo ./x
time = 100015 uS
pi@raspberrypi ~/bcm2835-1.43 $

Cheers.

Yanxiang Mao

unread,
Mar 31, 2015, 12:22:55 AM3/31/15
to bcm...@googlegroups.com
I use a new SD card install the same image, it is work. Thank you all for help.

在 2015年3月31日星期二 UTC+8上午7:07:34,Mike McCauley写道:
Reply all
Reply to author
Forward
0 new messages