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?

(注意)M5StampS3 (LX7) のバイトオーダーを調べる(格納される時のバイトの並び)

Last updated at Posted at 2025-01-31

M5StampS3のバイトオーダーを調べる(格納される時のバイトの並び)

C++ Arduino アルゴリズム M5stack M5StampS3

参考

x 過去ログを見ょ!!!
x アルゴリズムは、あまり関係ないけど?
x 研究調査目的で非営利で引用しました。
x 「シリアルモニタ」は、なんどか開き直す
x 3.1.1
x unionは、共有体 (共用体)
x ビットとバイトの並びは、物理装置とコンパイラに依存する。
x 1番下のコメントにあるように厳密では、ない。

目的
メモリー内でのバイトの並びを調べる
共有体 (共用体)を使用した時のバイトの並び

結果

o_coq787.jpg

プログラム




//ser_byte_order_M5StampS3

void setup() {
  // put your setup code here, to run once:

  //シリアルの初期化
  Serial.begin(9600);
  Serial.println();
  //シリアルの待ちが0.5*9
  for (int i = 0; i < 9; i++) {
    delay(500);  //接続待ち
    Serial.print('.');
  }  //for
  Serial.println();

  union {
    uint32_t b4;
    uint16_t b2[2];
    uint8_t  b1[4];
  } bytes;

  bytes.b4 = 0x12345678;
  Serial.printf ("bytes.b4: %08X\n", bytes.b4);
  Serial.printf ("bytes.b2: %04X, %04X\n", bytes.b2[0], bytes.b2[1]);
  Serial.printf ("bytes.b1: %02X, %02X, %02X, %02X\n", bytes.b1[0], bytes.b1[1], bytes.b1[2], bytes.b1[3]);

}

void loop() {
  // put your main code here, to run repeatedly:

}


1
0
7

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?