简体   繁体   English

如何读取BeagleBone Black上的外部计时器?

[英]How to read the external timer counter on the BeagleBone Black?

I need to count the transitions of a 50KHz binary signal using a BBB. 我需要使用BBB计算50KHz二进制信号的跃迁。 I think using the TIMER4 triggered by the external signal connected to the pin P8.07 would be the easiest way. 我认为使用由连接到引脚P8.07的外部信号触发的TIMER4是最简单的方法。

So, I issued the following commands to load the proper cape and setup the pin as a timer : 因此,我发出了以下命令来加载适当的海角并将引脚设置为计时器:

./config-pin overlay cape-universaln
./config-pin P8.07 timer

Everything seems to work and nothing appears in dmesg . 一切似乎都正常运行, dmesg什么也没有出现。

My question is : How can I read the value of TIMER4 ? 我的问题是 :如何读取TIMER4的值? I looked in SysFs and find nothing interesting. 我查看了SysF,没有发现任何有趣的东西。 Nothing in /dev as well. /dev中也没有。 How can I retrieve the value of the timer counter I just setup ? 如何获取刚刚设置的计时器的值? I'm open to a C/C++ solution as well, but I would like to avoid doing kernel-space programming. 我也对C / C ++解决方案持开放态度,但我想避免进行内核空间编程。

I'm using the latest Ubuntu Linux for BeagleBone, kernel 4.1.10-ti-r21. 我正在为BeagleBone使用最新的Ubuntu Linux,内核4.1.10-ti-r21。

With a little googling I see a pps driver for the AM335x DMTimer subsystem here: https://github.com/ddrown/pps-gmtimer 稍作搜索,我在这里看到了AM335x DMTimer子系统的pps驱动程序: https : //github.com/ddrown/pps-gmtimer

It looks like it hasn't been merged upstream and the README gives instructions on building it into the 3.8 kernel - you could revert back to 3.8, or you could adapt that for 4.1, in which case you may need to tweak the Device Tree overlay as well for the newer version of the dtc compiler that's in 4.1. 似乎它尚未被上游合并,并且自述文件给出了将其构建到3.8内核中的说明-您可以还原到3.8,或者可以将其改编为4.1,在这种情况下,您可能需要调整设备树覆盖以及4.1中较新版本的dtc编译器。

You could also write a pulse counter firmware for the PRU (with only a 50KHz input it wouldn't need to be very optimized at all to catch every pulse). 您还可以为PRU编写一个脉冲计数器固件(只需输入50KHz,就不需要完全优化以捕获每个脉冲)。 You could send a signal to the ARM every so often and catch that in your userspace program. 您可以经常向ARM发送信号并将其捕获到您的用户空间程序中。

Another option would be to directly access the DMTimer registers from userspace using mmap to map the /dev/mem file (example of this method for GPIO here ), but that's a pretty "hacky" way to do it, and it's generally frowned upon in the GNU/Linux world to do that sort of stuff from userspace instead of from kernal space. 另一个选择是使用mmap从用户空间直接访问DMTimer寄存器,以映射/dev/mem文件( 此处为GPIO的此方法的示例),但这是一种非常“ hacky”的方式,通常对此不以为然。 GNU / Linux世界可以从用户空间而不是内核空间进行此类操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM