3
3

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 5 years have passed since last update.

nRF52でリセットボタンをGPIOに使う

Posted at

nRF52840 では RESET は GPIOの P0.18 に割り当てられている。RESETの機能は他のピンに移動できないらしい

が、リセット機能を無効にして通常のGPIOとして使うことはできる。

環境

  • Raytac MDBT50Q-DB ( Nordic nRF52840 SoC )
  • Nordic nRF5 SDK v15.2.0
  • SEGGER Embedded studio for ARM V4.10a
  • J-link v9(中華製)

プロジェクト設定

サンプルプログラムのblinkyを例に取ると、

( examples/peripheral/blinky/pca10056/mbr/ses を使うとして )

blinky_pca10056_mbr.emProject 内の c_preprocessor_definitions に指定されている


CONFIG_GPIO_AS_PINRESET;

を削除

ALLERASE

これだけでプロジェクト設定はOKだが、既にリセット設定が書き込まれた nRF52840 を使う場合は過去のレジスタ設定をクリアしておかないといけない。

Segger Embedded Studio の、Target - Connect J-link すると、Target - Erase All ができるようになる。
Erase Allを実行すると(数十表かかる)、過去の設定を無効にできる。

なお、リセットが有効なプロジェクトから、無効に変更した場合は Build - Clean Solution も忘れないこと

使用例


  // プルアップ付きインプットモードに設定
  nrf_gpio_cfg_input(NRF_GPIO_PIN_MAP(0,18),NRF_GPIO_PIN_PULLUP);  

・・・

  if( 0 == nrf_gpio_pin_read(NRF_GPIO_PIN_MAP(0,18))){
         // ボタンが押された処理
  }

これで、P0.18をGNDに接続すると元々はリセットがかかるが、うまく設定ができていれば「// ボタンが押された処理」が実行される。

3
3
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
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?