Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

処理時間を計測する #9

Open
ShotaAk opened this issue Sep 30, 2023 · 5 comments
Open

処理時間を計測する #9

ShotaAk opened this issue Sep 30, 2023 · 5 comments

Comments

@ShotaAk
Copy link
Contributor

ShotaAk commented Sep 30, 2023

計測方法

  auto start_time = micros();
  M5.update();
  M5_LOGI("elapsed time [us]:%d", micros() - start_time);
@ShotaAk
Copy link
Contributor Author

ShotaAk commented Sep 30, 2023

M5.update() : 約 11.5 usec

  auto start_time = micros();
  M5.update();
  M5_LOGI("elapsed time [us]:%d", micros() - start_time);

@ShotaAk
Copy link
Contributor Author

ShotaAk commented Sep 30, 2023

コマンド受信(データがないとき): 58 ~ 68 usec

  auto start_time = micros();
  if(g_receiver.receive()) {
    // M5_LOGD("Received command!");
  }
  M5_LOGI("elapsed time:%d", micros() - start_time);

@ShotaAk
Copy link
Contributor Author

ShotaAk commented Sep 30, 2023

I2Cのデータ送信(100kHz):819 ~ 827 usec

  auto start_time = micros();
  const unsigned char SLAVE_ADDR = 0x54;
  Wire1.beginTransmission(SLAVE_ADDR);
  Wire1.write(send_data, DATA_SIZE);
  
  if(Wire1.endTransmission() == 0) {
    // M5_LOGI("Sent command!");
  } else {
    M5_LOGD("Failed to send command!");
  }
  M5_LOGI("elapsed time:%d", micros() - start_time);

@ShotaAk
Copy link
Contributor Author

ShotaAk commented Sep 30, 2023

loop関数:880 ~ 910 usec

i2cのクロックを400kHzに変更後:350 ~ 360 usec

unsigned long start_time = 0;
void loop() {
  M5_LOGI("elapsed time:%d", micros() - start_time);
  start_time = micros();

@ShotaAk
Copy link
Contributor Author

ShotaAk commented Sep 30, 2023

I2Cのデータ送信(400kHz):270 ~ 273 usec

  Wire1.begin(M5.In_I2C.getSDA(), M5.In_I2C.getSCL(), 400000);

  auto start_time = micros();
  const unsigned char SLAVE_ADDR = 0x54;
  Wire1.beginTransmission(SLAVE_ADDR);
  Wire1.write(send_data, DATA_SIZE);
  
  if(Wire1.endTransmission() == 0) {
    // M5_LOGI("Sent command!");
  } else {
    M5_LOGD("Failed to send command!");
  }
  M5_LOGI("elapsed time:%d", micros() - start_time);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant