Skip to content

Commit bcce65a

Browse files
committed
Small update, that ensures that we only switch to 1Mhz once
1 parent a26af52 commit bcce65a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

libraries/MySensors/examples/MysensorMicro/MysensorMicro.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ float lastTemperature = -100;
6161
int lastHumidity = -100;
6262
long lastBattery = -100;
6363

64+
bool highfreq = true;
6465

6566
void setup() {
6667

@@ -110,7 +111,7 @@ void loop() {
110111

111112
// When we wake up the 5th time after power on, switch to 1Mhz clock
112113
// This allows us to print debug messages on startup (as serial port is dependend on oscilator settings).
113-
if (measureCount == 5) switchClock(1<<CLKPS2); // Switch to 1Mhz for the reminder of the sketch, save power.
114+
if ((measureCount == 5) && highfreq) switchClock(1<<CLKPS2); // Switch to 1Mhz for the reminder of the sketch, save power.
114115

115116
if (measureCount > FORCE_TRANSMIT_INTERVAL) { // force a transmission
116117
forceTransmit = true;
@@ -208,6 +209,7 @@ void switchClock(unsigned char clk)
208209
CLKPR = 1<<CLKPCE; // Set CLKPCE to enable clk switching
209210
CLKPR = clk;
210211
sei();
212+
highfreq = false;
211213
}
212214

213215

0 commit comments

Comments
 (0)