LoginSignup
0
0

More than 1 year has passed since last update.

WioLTEでSDカードを使う方法

Last updated at Posted at 2022-03-17

経緯

WioLTEでSDカードを使う時にはSDforWioLTEを利用する例が多い。
しかし手元のWioLTEでは上手く動かなかった
Wio LTE JP Version v1.3b
Arduino v1.8.19
SeeedJP STM32 Bords v1.8.0
WioLTEforArduino v2.13.0
SDforWioLTE v1.0.0
microSDHCカード32GB

SDReadWrite.inoの実行結果
--- START ---------------------------------------------------
### I/O Initialize.
### Power supply ON.
### Initialize SD card.
### ERROR! ###

SD.begin()がエラーを返すので調べた。

配線

SDカードへの配線は次の通り。

Adruino Pin # STM32 Pin 線名 SD card Pin Pin説明
42 PC10 SDIO_D2 DAT2 N.C.
43 PC11 SDIO_D3 CD/DAT3 CS
48 PD2 SDIO_CMD CMD MOSI
44 PC12 SDIO_CK CLK CLK
40 PC8 SDIO_D0 DAT0 MISO
41 PC9 SDIO_D1 DAT1 N.C
15 PA15 SDIO_POWR VDD 3.3V

原因

Arduino/libraries/SDforWioLTE-master/src/utility/Sd2Card.h
/** SPI Master Out Slave In pin */
uint8_t const SPI_MOSI_PIN = 50; //11;

MOSIの番号を48に修正。

修正後 Sd2Card.h
/** SPI Master Out Slave In pin */
uint8_t const SPI_MOSI_PIN = 48; //50; //11;

結果

SDReadWrite.inoの実行結果
--- START ---------------------------------------------------
### I/O Initialize.
### Power supply ON.
### Initialize SD card.
### Writing to test.txt.
### Reading from test.txt.
test.txt:
testing 1, 2, 3.
### Setup completed.

動いた。めでたしめでたし。

余談

ボードマネージャv1.7.0ではPD2のPin番号は50だったが、v1.8.0では48に変わった。

Pin番号は以下のファイルで定義されている。
C:\Users\{ユーザ名}\AppData\Local\Arduino15\packages\SeeedJP\hardware\stm32\1.8.0\variants\WIO_LTE\variant_WIO_LTE.cpp

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