最新情報
ナウいマイコン PSoC4200 と m5stack の Delay関数の注意点(バラつき)
m5stack を使用して
delayMicroseconds()
#include <Arduino.h>
#include <M5Stack.h>
#define pin_sw	2	// 
#define pin_led	5	// 
unsigned int led_on_time = 2;		// LED ON 時間 (uS)
void setup() {
  // put your setup code here, to run once:
	M5.begin(true, false, true, true);
	M5.Lcd.setTextSize(3);
	M5.Lcd.setCursor(20, 0);
	M5.Lcd.println("Delay TEST");
	pinMode(pin_sw, INPUT_PULLUP);	// プルアップ入力に設定
	pinMode(pin_led, OUTPUT);			// 出力に設定
	digitalWrite(pin_led,1);
	delay(250);
	digitalWrite(pin_led,0);
}
void loop() {
  // put your main code here, to run repeatedly:
	if (digitalRead(pin_sw) == 0){
		
		digitalWrite(pin_led,1);
		delayMicroseconds(led_on_time);		// LED ON
		digitalWrite(pin_led,0);
		
		delay(10);
		while(digitalRead(pin_sw) == 0)	// SW 離されるまで
		delay(10);
	}
}
なるべく同じ条件で PSoC4 でもテストしてみます。
#include "project.h"
uint16 led_on_time = 2;		// LED ON 時間 (uS)
int main(void)
{
    CyGlobalIntEnable; /* Enable global interrupts. */
    /* Place your initialization/startup code here (e.g. MyInst_Start()) */
	LED_Write(1);
	CyDelay(250);
	LED_Write(0);
    for(;;)
    {
        /* Place your application code here. */
		
		if (SW_Read() == 0){
		
			LED_Write(1);
			CyDelayUs(led_on_time);		// LED ON
			LED_Write(0);
		
			CyDelay(10);
			while(SW_Read() == 0)	// SW 離されるまで
			CyDelay(10);
	
		}
	}
}
結果:
m5stack 計測例
PSoC4200 計測例
計測中の様子
ナウいマイコン PSoC4200 と m5stack の Delay関数の注意点(バラつき) – YouTube
測定結果を表にまとめてみました
| 単位uS | ||
| PSoC4 | M5Stack | |
| 1 | 4.370 | 2.065 | 
| 2 | 4.370 | 2.000 | 
| 3 | 4.370 | 3.100 | 
| 4 | 4.370 | 2.550 | 
| 5 | 4.370 | 2.555 | 
| 6 | 4.370 | 2.550 | 
| 7 | 4.370 | 3.100 | 
| 8 | 4.370 | 2.550 | 
| 9 | 4.370 | 2.550 | 
| 10 | 4.370 | 2.550 | 
| 11 | 4.370 | 2.550 | 
| 12 | 4.370 | 2.615 | 
| 13 | 4.370 | 2.550 | 
| 14 | 4.370 | 3.165 | 
| 15 | 4.370 | 3.105 | 
| 16 | 4.370 | 3.100 | 
| 17 | 4.370 | 2.550 | 
| 18 | 4.370 | 3.105 | 
| 19 | 4.370 | 3.100 | 
| 20 | 4.370 | 3.100 | 
| 21 | 4.370 | 2.555 | 
| 22 | 4.370 | 3.100 | 
| 23 | 4.370 | 2.065 | 
| 24 | 4.370 | 3.100 | 
| 25 | 4.370 | 2.550 | 
| 26 | 4.370 | 2.615 | 
| 27 | 4.370 | 2.550 | 
| 28 | 4.370 | 2.620 | 
| 29 | 4.370 | 2.550 | 
| 30 | 4.370 | 2.555 | 
| 31 | 4.370 | 3.100 | 
| 32 | 4.370 | 3.100 | 
PSoC4200 は
4.370uS
m5stack は
最小 2.000uS めっちゃ速い!関数に飛んだり、レジスタ格納したりいつやってんだ?????
最大 3.165uS
という結果です。
m5stack はとても速いですが、安定という意味ではイマイチ
PSoC4200はちょっと遅いけど、超安定という結果です。
m5stack は CPUがマルチコアで、Arduino環境をOS(FreeRTOS)が作り出し管理しているらしい・・・・・・・・・(たぶん)。
Bluetooth、WiFiなど、てんこ盛り状態の超高性能マイコンですが、奥の奥まで使いこなすのは(私では)大変そうです。
Bluetooth、WiFiモジュールとして割りきって使っていこうと思います。
加納 大裕 (かのう だいゆう)
- 
- 2025.10.29
 - 薪ストーブ実演展示 東栄フェスティバル
 
 - 
- 2025.10.29
 - 薪ストーブ実演展示、売木村秋色感謝祭
 
 - 
- 2025.09.26
 - 薪ストーブ、新城軽トラ市に出店します。
 
 - 
- 2025.09.05
 - 薪ストーブ出展 GP CAMP.Fes2025
 
 - 
- 2025.08.29
 - なぜ加納製作所の薪ストーブは薪を炭にしてから燃焼させるのか?
 
 














