tokai-student-rocket-project / H-58-Avionics

H-58搭載計器 | 2023年度 夏季 能代 NOGO
MIT License
3 stars 0 forks source link

STM32開発環境 #20

Closed waiwai2525 closed 1 year ago

waiwai2525 commented 1 year ago

Nucleo-STM32F401RE の ArduinoIDE 設定

スクリーンショット 2023-03-15 16 50 59
waiwai2525 commented 1 year ago

環境構築は いろいろなマイコンボードに使えるArduino IDE。環境構築メモ | マルツオンライン この辺を参考に

waiwai2525 commented 1 year ago

Mac環境でSetupSTM32CubeProgrammer.appが実行できない時は STM32Cubeprogrammer fails to install in MacOS

Rather than launch the STM32Cube installer app, I selected the app, then Ctrl-Clicked to select "Show Package Contents". Next, Navigate to Contents>>macOs then Ctrl-Click on SetupSTM32CubeProgrammer-1_2_1_macos and select "Open" and the installer will run

waiwai2525 commented 1 year ago

基本的にArduinoと同じように扱うことができるが、Serial(UART)やWire(I2C)などの外部接続はピン番号が異なっていることがあるため注意

waiwai2525 commented 1 year ago

I2Cは内部ブルアップの操作を方法がわからない (HALを使えばできるのかも)ので外部プルアップ抵抗10kΩをつける 初期では内部プルアップは有効化されていない

waiwai2525 commented 1 year ago

テストで動いたコード

// I2CDev の MPU6050 ライブラリは普通に使えた
#include "MPU6050.h"

MPU6050 accelgyro;

int16_t ax, ay, az;
int16_t gx, gy, gz;

void setup() {
  // I2C のピン番号を確認して設定する
  Wire.setSDA(PB_9);
  Wire.setSCL(PB_8);
  Wire.begin();
  // Fast-mode 400kbps に設定
  Wire.setClock(400000);

  // Serial2 が Tx:PA2, Rx:PA3
  Serial2.begin(115200);

  accelgyro.initialize();
}

void loop() {
  accelgyro.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
  Serial2.println(ax);
}
TsutsumiHiroki commented 1 year ago

[Starting] Uploading sketch 'FUTABA\servo\servo.ino' [Warning] Output path is not specified. Unable to reuse previously compiled files. Build will be slower. See README. C:/Users/USERNAME/AppData/Local/Arduino15/packages/STMicroelectronics/tools/STM32Tools/2.1.1/stm32CubeProg.sh: line 141: STM32_Programmer_CLI.exe: not found Error during Upload: Failed uploading: uploading error: exit status 127 IntelliSense configuration already up to date. To manually rebuild your IntelliSense configuration run "Ctrl+Alt+I" [Error] Uploading sketch 'FUTABA\servo\servo.ino': Exit with code=1

こんなエラーが出た場合の対処法 STM32_Programmer_CLI.exeがないよ~と言っているので STM32CubeProgをインストールする。

image

スクロールして少し待つと表示されるので自分のOSに合うものをインストールしてください。

STアカウントを持っていない場合はメールアドレスの登録が必要になります。

waiwai2525 commented 1 year ago

https://github.com/tokai-student-rocket-project/H-58-Avionics/issues/46 STM32CubeIDE

waiwai2525 commented 1 year ago

コンパイル時に"fatal error: {ライブラリ名}.h: No such file or directory"と出た場合の対処法

ライブラリ情報を更新

arduino-cli lib update-index

インストール済みのライブラリを表示

arduino-cli lib list

IDEで使えていたライブラリでも、CLIではインストールされていない場合があるので適宜インストールする。

arduino-cli lib install {ライブラリ名}

vscode+Arduino拡張機能の環境でIDEからCLIに変更したときに複数のライブラリでこの現象が起きた。

TsutsumiHiroki commented 1 year ago

基本的にArduinoのエコシステムを採用していくためSTM32開発環境の構築は行わない方向で進んでいく.