-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathExperiencia_ESP32v2.ino
43 lines (34 loc) · 1.47 KB
/
Experiencia_ESP32v2.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// https://github.com/espressif/arduino-esp32/blob/f32083a6d0afad8efc4d52b11091ccf55249dc29/cores/esp32/esp32-hal-timer.c
hw_timer_t *meuTempo = NULL; // Instancia do timer
unsigned int prescaler = 80; // Prescaler do contador de timer
unsigned long timeTA, timeTB, timeTC, timeTD, timeTE = 0;
//----------------------------------------------------------------------------------
void setup()
{
Serial.begin(115200); // Inicializa a serial
meuTempo = timerBegin(0, prescaler, true); // usa o timer 0 com o prescaler definido
timerStart(meuTempo);
}
//----------------------------------------------------------------------------------
void loop()
{
timerWrite(meuTempo, 0);
timeTA = timerRead(meuTempo);
delayMicroseconds (10000);
timeTA = timerRead(meuTempo);
delayMicroseconds (10000);
timeTB = timerRead(meuTempo);
delayMicroseconds (10000);
timeTC = timerRead(meuTempo);
delayMicroseconds (10000);
timeTD = timerRead(meuTempo);
delayMicroseconds (10000);
timeTE = timerRead(meuTempo);
Serial.println();
Serial.print("TA "); Serial.println(timeTA);
Serial.print("TB "); Serial.println(timeTB);
Serial.print("TC "); Serial.println(timeTC);
Serial.print("TD "); Serial.println(timeTD);
Serial.print("TE "); Serial.println(timeTE);
}
//------------------------------------------------------------------------------------