-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathraw_data.ino
More file actions
26 lines (23 loc) · 866 Bytes
/
raw_data.ino
File metadata and controls
26 lines (23 loc) · 866 Bytes
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
#include <compat/deprecated.h>
#include <FlexiTimer2.h>
#define SAMPFREQ 256 // ADC sampling rate 256
#define TIMER2VAL (1024/(SAMPFREQ)) // Set 256Hz sampling frequency
volatile unsigned char CurrentCh=0; //Current channel being sampled.
volatile unsigned int ADC_Value = 0; //ADC current value
volatile unsigned int smpCounter;
void setup() {
noInterrupts(); // Disable all interrupts before initialization
smpCounter = 0; // setup sample counter
FlexiTimer2::set(TIMER2VAL, Timer2_Overflow_ISR);
FlexiTimer2::start();
Serial.begin(57600);
interrupts(); // Enable all interrupts after initialization has been completed
}
void Timer2_Overflow_ISR()
{
ADC_Value = analogRead(CurrentCh);
Serial.println(ADC_Value); // print sample
}
void loop() {
__asm__ __volatile__ ("sleep");
}