You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/ADCUtils.h
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -31,6 +31,7 @@
31
31
32
32
// External Reference Current is 150 uA for 5 V and 100 uA for 3.5 V
33
33
#defineREADING_FOR_AREF 1024L // Datasheet 24.2: The minimum value represents GND and the maximum value represents the voltage on the AREF pin minus 1 LSB
34
+
#defineMAX_ADC_VALUE 1023L
34
35
35
36
// PRESCALE4 => 13 * 4 = 52 microseconds per ADC conversion at 1 MHz Clock => 19,2 kHz
36
37
#defineADC_PRESCALE2 1 // 26 microseconds per ADC conversion at 1 MHz
Copy file name to clipboardExpand all lines: src/ADCUtils.hpp
+73-13Lines changed: 73 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -27,6 +27,7 @@
27
27
28
28
#include"ADCUtils.h"
29
29
#if defined(ADC_UTILS_ARE_AVAILABLE) // set in ADCUtils.h, if supported architecture was detected
30
+
#defineADC_UTILS_ARE_INCLUDED
30
31
31
32
#if !defined(STR)
32
33
#defineSTR_HELPER(x) #x
@@ -41,7 +42,7 @@
41
42
* with INTERNAL you can calibrate your ADC readout. For my Nanos I measured e.g. 1060 mV and 1093 mV.
42
43
*/
43
44
#if !defined(ADC_INTERNAL_REFERENCE_MILLIVOLT)
44
-
#defineADC_INTERNAL_REFERENCE_MILLIVOLT1100L// Change to value measured at the AREF pin. If value > real AREF voltage, measured values are > real values
45
+
#defineADC_INTERNAL_REFERENCE_MILLIVOLT1100UL// Change to value measured at the AREF pin. If value > real AREF voltage, measured values are > real values
45
46
#endif
46
47
47
48
// Union to speed up the combination of low and high bytes to a word
@@ -66,6 +67,11 @@ union WordUnionForADCUtils {
66
67
#else
67
68
//#define LOCAL_DEBUG // This enables debug output only for this file
68
69
#endif
70
+
#if defined(INFO)
71
+
#defineLOCAL_INFO
72
+
#else
73
+
//#define LOCAL_INFO // This enables debug output only for this file
74
+
#endif
69
75
70
76
/*
71
77
* Persistent storage for VCC value
@@ -79,6 +85,27 @@ uint8_t sVCCTooLowCounter = 0;
79
85
80
86
/*
81
87
* Conversion time is defined as 0.104 milliseconds by ADC_PRESCALE in ADCUtils.h.
88
+
* Use previous settings
89
+
*/
90
+
uint16_treadADCChannel() {
91
+
WordUnionForADCUtils tUValue;
92
+
93
+
// ADCSRB = 0; // Only active if ADATE is set to 1.
94
+
// ADSC-StartConversion ADIF-Reset Interrupt Flag - NOT free running mode
0 commit comments