Skip to content

cannot use rtcounter in high I2C SCL frequency #13

@Tiryoh

Description

@Tiryoh

特定の条件下ではrtcounterが使用できない場合があります。詳しくは以下の「考えられる原因と対処方法」に書いていますが、CPUのgovernorをpowersaveに指定し、CPUクロックを下げることでエラーを回避してrtcounterを使用することができるようになります。

環境

Raspberry Pi 3 Model B

OS

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.1 LTS
Release:        18.04
Codename:       bionic
$ uname -a
Linux ubuntu 4.15.0-1027-raspi2 #29-Ubuntu SMP PREEMPT Wed Oct 24 08:56:30 UTC 2018 aarch64 aarch64 aarch64 GNU/Linux

rt-net/RaspberryPiMouse のバージョン

$ git log -n 1
commit 864acceef45eac90b0c7f8342e0371468ea67e62

現象

i2c-toolsでデバイスに直接アクセスしようとしてもRead faildとなる

$ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: 10 11 -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
$ sudo i2cget -y 1 0x10 0x10 w
Error: Read failed

デバイスドライバをインストールする際にrtcounternot found, or wrongとなる

$ cd RaspberryPiMouse/src/drivers/
$ make
$ sudo insmod rtmouse.ko
$ dmesg
[   70.775579] rtmouse: loading driver...
[   70.776570] rtmouse: rtcounter not found, or wrong i2c device probed
[   70.777546] rtmouse: rtcounter not found, or wrong i2c device probed
[   70.886544] rtmouse: mcp3204 probed
[   70.886606] rtmouse: 15 devices loaded.
[   70.886610] rtmouse: module installed at 4294910017

I2Cの波形

エラーが出る場合のI2Cの波形

tek00027

エラーが出ない場合のI2Cの波形

  • モータのスイッチのオン/オフ切り替えを繰り返すとエラーが出ず、rtcounterにアクセスできる場合があります。
    tek00028

考えられる原因と対処方法

今回使用した環境では、デフォルトでI2Cのbaudrateは100kHzですが、CPUのクロックが600MHzまで下がるとI2Cのbaudrateが62.5kHzまで下がるようです。
I2Cのbaudrateを62.5kHzまで下げるとrtcounterへのアクセスに失敗しません。以下の方法でCPUのクロックを下げ、I2Cのbaudrateを62.5kHzにすることができます。

$ sudo apt install cpufrequtils
$ sudo cpufreq-set -g powersave

参考

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: AbandonedThe issue or Pull Request is wontfixType: BugBug or Bug fixes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy