-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathExample1_EnableDisable.ino
42 lines (36 loc) · 1.37 KB
/
Example1_EnableDisable.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
//Burst Mode example
//TEST_PIN is toggled as fast as possible, with burst mode enable and disabled.
//Use a logic analyzer to view the difference in output
#include "BurstMode.h"
#define TEST_PIN D2 //Change to whatever pin you would like
#define NUM_TOGGLES 20 //Number of times to toggle the gpio as an example task
void setup() {
Serial.begin(115200);
Serial.println("BurstMode Example1 - Enable and Disable");
}
void loop() {
long startTime, endTime;
enableBurstMode(); //Go to 96MHz
//Toggle the with digital write as fast as possible, 20 times
startTime = micros();
for(int i = 0; i < NUM_TOGGLES; i++)
{
digitalWrite(TEST_PIN, HIGH);
digitalWrite(TEST_PIN, LOW);
}
endTime = micros();
Serial.printf("Time (in microseconds) to toggle GPIO %d times = %d, at clock speed %d \r\n",
NUM_TOGGLES, (endTime - startTime), getCpuFreqMHz());
disableBurstMode(); //Go back to 48MHz
//Toggle the with digital write as fast as possible, 20 times
startTime = micros();
for(int i = 0; i < NUM_TOGGLES; i++)
{
digitalWrite(TEST_PIN, HIGH);
digitalWrite(TEST_PIN, LOW);
}
endTime = micros();
Serial.printf("Time (in microseconds) to toggle GPIO %d times = %d, at clock speed %d \r\n",
NUM_TOGGLES, (endTime - startTime), getCpuFreqMHz());
delay(1000);
}