-
Notifications
You must be signed in to change notification settings - Fork 6
/
Timer.ino
38 lines (27 loc) · 906 Bytes
/
Timer.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
#include <nrf.h>
#include "nrf_timer.h"
#include "Timer.h"
#define OUT_PIN 25
#define nrf_timer_num (1)
#define cc_channel_num (0)
TimerClass timer(nrf_timer_num, cc_channel_num);
void setup() {
Serial.setPins(0, 27);
Serial.begin(230400);
Serial.println("Starting...");
pinMode(OUT_PIN, OUTPUT);
digitalWrite(OUT_PIN, 0);
timer.attachInterrupt(&Timer_callback, 300); // microseconds
}
void Timer_callback() {
digitalWrite(OUT_PIN, 1); // to visualize when it was called
digitalWrite(OUT_PIN, 0);
timer.attachInterrupt(&Timer_callback, 300); // microseconds
}
void loop() {
// Sleep
__WFE(); // Enter System ON sleep mode (OFF mode would stop timers)
__SEV(); // Make sure any pending events are cleared
__WFE(); // More info about this sequence:
// devzone.nordicsemi.com/f/nordic-q-a/490/how-do-you-put-the-nrf51822-chip-to-sleep/2571
}