1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

STM32C011F4P6、SPIで遊ぶ(最終章)(実装編)

Last updated at Posted at 2025-08-27

参考

いろいろ注意

  • 過去ログを見よ

結果

  • PA5 SPIクロック (SCK)
  • PA7 マスター出力、スレーブ入力のデータ (MOSI)
  • PB6 スレーブ出力、マスター入力のデータ (SOMI)

Screenshot from 2025-08-28 06-11-53.png

プログラム



//SPI_test1_C0116


//インクルド
#include <Arduino.h>
#include <SPI.h>


//定義
#define DW    digitalWrite

//#define s60() for(ii=0;ii<60;ii++)delay(1000);
#define s60() delay(1000);


//初期化
void setup() {
    
  // SPIの初期化
  SPI.setMISO(PB6);
  SPI.beginTransaction( SPISettings(8000000, MSBFIRST, SPI_MODE0) );

} //setup


//メインループ
void loop() {

  //0
  SPI.transfer(0x00);//DW(SS,HIGH);DW(SS,LOW);
  SPI.transfer(0x00);//DW(SS,HIGH);DW(SS,LOW);
  s60();
  
  //1
  SPI.transfer(0x00);//DW(SS,HIGH);DW(SS,LOW);
  SPI.transfer(0x55);//DW(SS,HIGH);DW(SS,LOW);
  s60();
  
  //2
  SPI.transfer(0x00);//DW(SS,HIGH);DW(SS,LOW);
  SPI.transfer(0xaa);//DW(SS,HIGH);DW(SS,LOW);
  s60();
  
  //3
  SPI.transfer(0x00);//DW(SS,HIGH);DW(SS,LOW);
  SPI.transfer(0xff);//DW(SS,HIGH);DW(SS,LOW);
  s60();

} //loop



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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?