質問編集履歴
2
修正
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
割り込みとvolatileについて
|
1
|
+
割り込みとvolatile修飾子について
|
test
CHANGED
@@ -116,7 +116,7 @@
|
|
116
116
|
|
117
117
|
static uint32_t before = 0;
|
118
118
|
|
119
|
-
uint32_t current = millis();
|
119
|
+
uint32_t current = millis(); //ミリ秒時間取得
|
120
120
|
|
121
121
|
|
122
122
|
|
1
コメント追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -66,6 +66,8 @@
|
|
66
66
|
|
67
67
|
|
68
68
|
|
69
|
+
//シリアル受信判定
|
70
|
+
|
69
71
|
if(Serial.available() > 0)
|
70
72
|
|
71
73
|
{
|
@@ -74,7 +76,7 @@
|
|
74
76
|
|
75
77
|
{
|
76
78
|
|
77
|
-
recv = Serial.read();
|
79
|
+
recv = Serial.read(); //1byteずつ吐き出し
|
78
80
|
|
79
81
|
if(recv != -1)
|
80
82
|
|
@@ -93,6 +95,8 @@
|
|
93
95
|
else
|
94
96
|
|
95
97
|
{
|
98
|
+
|
99
|
+
//シリアルデータなし
|
96
100
|
|
97
101
|
break;
|
98
102
|
|
@@ -114,11 +118,15 @@
|
|
114
118
|
|
115
119
|
uint32_t current = millis();
|
116
120
|
|
121
|
+
|
122
|
+
|
123
|
+
//2000ミリ秒経過判定
|
124
|
+
|
117
125
|
if(getTime(current, before) >= 2000)
|
118
126
|
|
119
127
|
{
|
120
128
|
|
121
|
-
Serial.print("Print!");
|
129
|
+
Serial.println("Print!");
|
122
130
|
|
123
131
|
before = current;
|
124
132
|
|
@@ -148,6 +156,8 @@
|
|
148
156
|
|
149
157
|
{
|
150
158
|
|
159
|
+
//オーバーフロー時
|
160
|
+
|
151
161
|
gettime = a + (0xFFFFFFFF - b);
|
152
162
|
|
153
163
|
}
|