2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

WioTerminalのBCM20とBCM21の定義が間違っている件

Last updated at Posted at 2020-05-24

どんな内容か?

WioTerminalのGPIO定義に間違いがあることに気づいた話です。(Arduino IDE環境)
多分、すぐ修正されると思いますがもし同じハマりに遭遇しないために簡単にまとめておきます。
※ BCM20, BCM21のvariant.hの定義がまちがっていると思う。
2020/06/14 本件は、Version 1.7.6で修正されていました。

image.png image.png ※画像は https://www.seeedstudio.com/Wio-Terminal-p-4509.html

現象

下記のようなプログラムをArduino IDEで記述しました。
BCM20を入力端子として利用し、LOの間は、シリアルでONを出力するコードです。

void setup() {
  pinMode(BCM20, INPUT_PULLUP);  
  Serial.begin(115200);
}

void loop() {
  if ( 0 == digitalRead(BCM20) )
  {
    Serial.println("on");
  }
}

そして、GNDとPCM20をショートするが、何も出力されない!

image.png

解析結果

WioTerminalのBCM20とBCM21の定義が逆のようです。
具体的には、variant.hに、

variant.h
# define BCM20 (53ul)
# define BCM21 (54ul)

とありますが、同じ端子に割り当てられたI2Sの番号定義は、下記のように定義されていますのでどうやらBCM20とBCM21の番号が逆のようです。

# define I2S_SDOUT (53ul)
# define I2S_SDIN (54ul)

対処方法

現時点(2020/05/24)では、BCM20とBCM21の定義は利用せずに、I2S_SDOUT、I2S_SDINを利用していた方が良さそうです。

void setup() {
  pinMode(I2S_SDIN, INPUT_PULLUP);  
  Serial.begin(115200);
}

void loop() {
  if ( 0 == digitalRead(I2S_SDIN) )
  {
    Serial.println("on");
  }
}

その他

単純な間違いではあるのですが、焦りました。基板を発注した直後でしたので修正依頼のメールを出して、解析作業したらこんな結果でしたのでひとまず安心しました。新しいおもちゃを利用するときは要注意ですね。

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?