LoginSignup
0
0

More than 1 year has passed since last update.

STM32G071でSPIで遊ぶ

Posted at

x 74hc164応用の表示装置 説明省略

目的
SPIのテスト
74hc164にクロックとデータを送る

o_cop258.jpg




#include <SPI.h>


#define DW    digitalWrite

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

void setup() {
  
  int ii; //ループカウンター
  
  // SPIの初期化
  SPI.begin(); // 11 12 13
  DW(SS, LOW); // 10
  SPI.setDataMode(SPI_MODE0);
  SPI.setBitOrder(MSBFIRST);
  SPI.setClockDivider(SPI_CLOCK_DIV8);  // 2Mhz
  
  //0
  SPI.transfer(0x00);DW(SS,HIGH);DW(SS,LOW);
  s60();
  
  //1
  SPI.transfer(0x55);DW(SS,HIGH);DW(SS,LOW);
  s60();
  
  //2
  SPI.transfer(0xaa);DW(SS,HIGH);DW(SS,LOW);
  s60();
  
  //3
  SPI.transfer(0xff);DW(SS,HIGH);DW(SS,LOW);
  
} //setup

void loop() {
} //loop




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