2
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.

STM32CubeIDEでタイマなどの初期化時の値を変数にする

Last updated at Posted at 2020-03-23

 STM32CubeIDEで、タイマなどのパラメータをDevice Configuration Tool(GUIの画面)ではなく、プログラム内でパラメータを指定したい場合がある。(あるでしょ?
 Device Configuration Toolで指定するパラメータは自動生成されるコードの初期化値なので、ユーザコード内で変更可能だが、それをするとコード生成の意味が薄れる。

 実は?このパラメータ入力では数値ではなく、変数も利用可能である。
image.png

図のようにパラメータ入力右の歯車のボタンから"No check"とすると変数を記入できる。

あとはユーザコード内でグローバル変数orマクロを定義することで、main.c内でパラメータを変更できる。

注:ここで指定した変数を初期化後に変更しても、自動生成された初期化関数を実行しないと、反映されません。
 また、ユーザコード内でパラメータの変更行うために自動生成された初期化関数を実行することは適切でないと思われます。
 あくまでの初期化時の初期値をコード内で指定できるだけの機能?です

2
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
2
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?