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

More than 1 year has passed since last update.

小マイコンのSPIの速度を測って遊ぶ1(STM32G071)

Last updated at Posted at 2023-11-03

目的
SPIの初期化の値による速度を
カウンターを使って計って遊ぶ

参考

●結果

DIV8 170KHz

o_cop743.jpg

DIV4 183KHz

o_cop744.jpg

DIV2 170KHz

o_cop745.jpg

●プログラム




//SPI_spped_ck_071_1

//ヘッダーファイル
#include <SPI.h>

//定義
#define DW    digitalWrite

//初期化
void setup() {

  // SPIの初期化
  SPI.begin(); // 11 12 13
  pinMode(SS, OUTPUT); // 10
  DW(SS, LOW); // 10
  SPI.setDataMode(SPI_MODE0);
  SPI.setBitOrder(MSBFIRST);

  //SPI.setClockDivider(SPI_CLOCK_DIV2);  // 8Mhz
  //SPI.setClockDivider(SPI_CLOCK_DIV4);  // 4Mhz
  SPI.setClockDivider(SPI_CLOCK_DIV8);  // 2Mhz

loop1_a:
  SPI.transfer(0b00011111); //1
  SPI.transfer(0b00011111); //2
  SPI.transfer(0b00011111); //3
  SPI.transfer(0b00011111); //4
  SPI.transfer(0b00011111); //5

  SPI.transfer(0b00011111); //6
  SPI.transfer(0b00011111); //7
  SPI.transfer(0b00011111); //8
  SPI.transfer(0b00011111); //9
  SPI.transfer(0b00011111); //10
goto loop1_a;

} //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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?