Skip to content

Commit 176675d

Browse files
committed
links
1 parent f7733bb commit 176675d

2 files changed

Lines changed: 75 additions & 75 deletions

File tree

megaavr/extras/Ref_Analog.md

Lines changed: 74 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -43,36 +43,36 @@ In some cases the voltage determines the maximum ADC clock speed. Call analogRef
4343
* You are on a Dx-series with an external reference of less than 1.8V
4444

4545

46-
| tinyAVR (0/1) | Voltage | Minimum Vdd | Number | Notes |
47-
|-----------------------------------------|---------|-------------|--------|-------|
48-
| `VDD` (default) | Vcc/Vdd | - | 16 | . |
49-
| `INTERNAL0V55` | 0.55 V | - | 0 | ADC clock needs to be 100kHz to 260 kHz to get accurate results |
50-
| `INTERNAL1V1` | 1.10 V | - | 1 | . |
51-
| `INTERNAL2V5` | 2.50 V | - | 2 | . |
52-
| `INTERNAL4V3` | 4.30 V | - | 3 | . |
53-
| `INTERNAL1V5` | 1.50 V | - | 4 | . |
54-
| `EXTERNAL` | - | - | 32 | 1+series only |
55-
56-
| tinyAVR (2-series) or Ex-series | Voltage | Minimum Vdd | Number | Notes |
57-
|-----------------------------------------|---------|-------------|--------|-------|
58-
| `VDD` (default) | Vcc/Vdd | | 0 | VDD Ref works at 6 MHz CLK ADC! |
59-
| `INTERNAL1V024` | 1.024 V | 2.5* V | 4 | 10-bit reading with 1.025 ref gives apx. 1 mv/ADC count |
60-
| `INTERNAL2V048` | 2.048 V | 2.5 V | 5 | 12-bit reading with 2.048 ref gives apx. 0.5 mv/ADC count |
61-
| `INTERNAL4V096` | 4.096 V | 4.55 V | 7 | 12-bit reading with 4.096 ref gives apx. 1 mv/ADC count |
62-
| `INTERNAL2V500` | 2.500 V | 2.7 V | 6 | . |
63-
| `INTERNAL4V1` (alias of INTERNAL4V096) | 4.096 V | 4.55 V | 7 | . |
64-
| `EXTERNAL` | - | Vdd | 2 | External ref works at 6 MHz CLK ADC! |
65-
66-
| AVR Dx/Ex-series | Voltage | Minimum Vdd | Number | Notes |
67-
|-----------------------------------------|---------|-------------|--------|---------|
68-
| `VDD` (default) | Vcc/Vdd | | 5 | . |
69-
| `INTERNAL1V024` | 1.024 V | 2.5* V | 0 | 10-bit reading with 1.025 ref gives apx. 1 mv/ADC count |
70-
| `INTERNAL2V048` | 2.048 V | 2.5 V | 1 | 12-bit reading with 2.048 ref gives apx. 0.5 mv/ADC count |
71-
| `INTERNAL4V096` | 4.096 V | 4.55 V | 2 | 12-bit reading with 4.096 ref gives apx. 1 mv/ADC count |
72-
| `INTERNAL2V500` | 2.500 V | 2.7 V | 3 | . |
73-
| `INTERNAL4V1` (alias of INTERNAL4V096) | 4.096 V | 4.55 V | 2 | . |
74-
| `EXTERNAL` | >=1.0 V | Vdd | 6 | Dx: CLK_ADC =< 500 kHz |
75-
| `EXTERNAL` | >=1.8 V | Vdd | 6 | Dx: No CLK_ADC restriction |
46+
| tinyAVR (0/1) | Voltage | Minimum Vdd | Number | Notes
47+
|-----------------------------------------|---------|-------------|--------|-------
48+
| `VDD` (default) | Vcc/Vdd | - | 16 |
49+
| `INTERNAL0V55` | 0.55 V | - | 0 | ADC clock needs to be 100kHz to 260 kHz to get accurate results
50+
| `INTERNAL1V1` | 1.10 V | - | 1 |
51+
| `INTERNAL2V5` | 2.50 V | - | 2 |
52+
| `INTERNAL4V3` | 4.30 V | - | 3 |
53+
| `INTERNAL1V5` | 1.50 V | - | 4 |
54+
| `EXTERNAL` | - | - | 32 | 1+series only
55+
56+
| tinyAVR (2-series) or Ex-series | Voltage | Minimum Vdd | Number | Notes
57+
|-----------------------------------------|---------|-------------|--------|-------
58+
| `VDD` (default) | Vcc/Vdd | | 0 | VDD Ref works at 6 MHz CLK ADC!
59+
| `INTERNAL1V024` | 1.024 V | 2.5* V | 4 | 10-bit reading with 1.025 ref gives apx. 1 mv/ADC count
60+
| `INTERNAL2V048` | 2.048 V | 2.5 V | 5 | 12-bit reading with 2.048 ref gives apx. 0.5 mv/ADC count
61+
| `INTERNAL4V096` | 4.096 V | 4.55 V | 7 | 12-bit reading with 4.096 ref gives apx. 1 mv/ADC count
62+
| `INTERNAL2V500` | 2.500 V | 2.7 V | 6 |
63+
| `INTERNAL4V1` (alias of INTERNAL4V096) | 4.096 V | 4.55 V | 7 |
64+
| `EXTERNAL` | - | Vdd | 2 | External ref works at 6 MHz CLK ADC!
65+
66+
| AVR Dx/Ex-series | Voltage | Minimum Vdd | Number | Notes
67+
|-----------------------------------------|---------|-------------|--------|---------
68+
| `VDD` (default) | Vcc/Vdd | | 5 |
69+
| `INTERNAL1V024` | 1.024 V | 2.5* V | 0 | 10-bit reading with 1.025 ref gives apx. 1 mv/ADC count
70+
| `INTERNAL2V048` | 2.048 V | 2.5 V | 1 | 12-bit reading with 2.048 ref gives apx. 0.5 mv/ADC count
71+
| `INTERNAL4V096` | 4.096 V | 4.55 V | 2 | 12-bit reading with 4.096 ref gives apx. 1 mv/ADC count
72+
| `INTERNAL2V500` | 2.500 V | 2.7 V | 3 |
73+
| `INTERNAL4V1` (alias of INTERNAL4V096) | 4.096 V | 4.55 V | 2 |
74+
| `EXTERNAL` | >=1.0 V | Vdd | 6 | Dx: CLK_ADC =< 500 kHz
75+
| `EXTERNAL` | >=1.8 V | Vdd | 6 | Dx: No CLK_ADC restriction
7676

7777
You can test like `if(getAnalogReference()==INTERNAL2V500)`, but if you try to say, print them, you just get a number. That's what is shown in the last column: contains the numerical value of the constants representing these references. Don't use those, then nobody will understand your code - including yourself in two weeks. However, if you are printing the results of `getAnalogReference()` or `getDACReference()`, these are the numbers you will see.
7878

@@ -118,26 +118,26 @@ analogReference() as you know takes only a single argument, and the overhead of
118118
In addition to reading from pins, you can read from a number of internal sources - this is done just like reading a pin, except the constant listed in the table below is used instead of the pin number:
119119

120120

121-
| AVR DA | AVR DB | AVR DD | AVR EA |
122-
|------------------|-------------------|-------------------|------------------|
123-
| `ADC_TEMPERATURE`| `ADC_VDDDIV10` | `ADC_VDDDIV10` | `ADC_VDDDIV10` |
124-
| `ADC_GROUND` * | `ADC_TEMPERATURE` | `ADC_TEMPERATURE` | `ADC_TEMPERATURE`|
125-
| `ADC_DACREF0` * | `ADC_GROUND` * | `ADC_GROUND` | `ADC_GROUND` |
126-
| `ADC_DACREF1` * | `ADC_DACREF0` * | `ADC_DACREF0` | `ADC_DACREF0` |
127-
| `ADC_DACREF2` * | `ADC_DACREF1` * | `ADC_DAC0` | `ADC_DACREF1` |
128-
| `ADC_DAC0` | `ADC_DACREF2` * | `ADC_VDDIO2DIV10` | `ADC_DAC0` |
129-
| | `ADC_DAC0` * | | |
130-
| | `ADC_VDDIO2DIV10` | | |
131-
132-
| tinyAVR 0/1-series | tinyAVR 2-series |
133-
|----------------------------------------|-------------------------------------|
134-
| `ADC_INTREF` | `ADC_VDDDIV10` |
135-
| `ADC_TEMPERATURE` | `ADC_TEMPERATURE` |
136-
| `ADC_DAC0` (1-series only) | `ADC_GROUND` (offset calibration?) |
137-
| `ADC_GROUND` (offset calibration?) | `ADC_DACREF0` |
138-
| `ADC_DACREF0` (alias of ADC_DAC0) | `ADC_DAC0` (alias of `ADC_DACREF0`) |
139-
| `ADC_PTC` (not particularly useful) | *see note* |
140-
| `ADC1_DACREF1` (16/32k 1-series only)† | |
121+
| AVR DA | AVR DB | AVR DD | AVR EA
122+
|------------------|-------------------|-------------------|------------------
123+
| `ADC_TEMPERATURE`| `ADC_VDDDIV10` | `ADC_VDDDIV10` | `ADC_VDDDIV10`
124+
| `ADC_GROUND` * | `ADC_TEMPERATURE` | `ADC_TEMPERATURE` | `ADC_TEMPERATURE`
125+
| `ADC_DACREF0` * | `ADC_GROUND` * | `ADC_GROUND` | `ADC_GROUND`
126+
| `ADC_DACREF1` * | `ADC_DACREF0` * | `ADC_DACREF0` | `ADC_DACREF0`
127+
| `ADC_DACREF2` * | `ADC_DACREF1` * | `ADC_DAC0` | `ADC_DACREF1`
128+
| `ADC_DAC0` | `ADC_DACREF2` * | `ADC_VDDIO2DIV10` | `ADC_DAC0`
129+
| | `ADC_DAC0` * | |
130+
| | `ADC_VDDIO2DIV10` | |
131+
132+
| tinyAVR 0/1-series | tinyAVR 2-series
133+
|----------------------------------------|-------------------------------------
134+
| `ADC_INTREF` | `ADC_VDDDIV10`
135+
| `ADC_TEMPERATURE` | `ADC_TEMPERATURE`
136+
| `ADC_DAC0` (1-series only) | `ADC_GROUND` (offset calibration?)
137+
| `ADC_GROUND` (offset calibration?) | `ADC_DACREF0`
138+
| `ADC_DACREF0` (alias of ADC_DAC0) | `ADC_DAC0` (alias of `ADC_DACREF0`)
139+
| `ADC_PTC` (not particularly useful) | *see note*
140+
| `ADC1_DACREF1` (16/32k 1-series only)† |
141141

142142
The Ground internal sources are presumably meant to help correct for offset error. On Classic AVRs they made a point of talking about offset cal for differential channels. They are thus far silent on this, despite a great number of tech briefs related to the new ADC has been coming out, greatly improving the quality of the available information
143143
DACREF0 is the the reference voltage for the analog comparator, AC0. On the 1-series, this is the same as the `DAC0` voltage (yup, the analog voltage is shared). Analog comparators AC1 and AC2 on 1-series parts with at least 16k of flash also have a DAC1 and DAC2 to generate a reference voltage for them (though it does not have an output buffer). On the 2-series, this is only used as the AC0 reference voltage; it cannot be output to a pin.
@@ -212,14 +212,14 @@ speed. This returns a `bool` - it is `true` if value is valid.
212212
213213
This value is used for all analog measurement functions.
214214
215-
| Part Series | Sample time<br/>(default) | Conversion time | Total analogRead() time | Default SAMPLEN* | ADC clock sample time |
216-
|-------------|--------------|-----------------|-------------------------|-----------------|-----------------------|
217-
| Classic AVR | 12 us | 92 us | 104 us | No such feature | 1.5 |
218-
| 0/1-series | 12 us | 8.8-10 us | 20.8-22 us | 7, 9, or 13 | 2 + SAMPLEN |
219-
| Dx (10-bit) | apx. 12 us | approx. 10 us | Approximately 21-22 us | 14 | 2 + SAMPLEN |
220-
| Dx (12-bit) | apx. 12 us | approx. 12 us | Approximately 23-24 us | 14 | 2 + SAMPLEN |
221-
| 2-series | apx. 6.4 us | approx. 5.6 us | Approximately 12 us | 15 | 1 + SAMPDUR |
222-
| EA-series | apx. 6.4 us | approx. 5.6 us | Approximately 12 us | 15 | 1 + SAMPDUR |
215+
| Part Series | Sample time<br/>(default) | Conversion time | Total analogRead() time | Default SAMPLEN* | ADC clock sample time
216+
|-------------|--------------|-----------------|-------------------------|-----------------|-----------------------
217+
| Classic AVR | 12 us | 92 us | 104 us | No such feature | 1.5
218+
| 0/1-series | 12 us | 8.8-10 us | 20.8-22 us | 7, 9, or 13 | 2 + SAMPLEN
219+
| Dx (10-bit) | apx. 12 us | approx. 10 us | Approximately 21-22 us | 14 | 2 + SAMPLEN
220+
| Dx (12-bit) | apx. 12 us | approx. 12 us | Approximately 23-24 us | 14 | 2 + SAMPLEN
221+
| 2-series | apx. 6.4 us | approx. 5.6 us | Approximately 12 us | 15 | 1 + SAMPDUR
222+
| EA-series | apx. 6.4 us | approx. 5.6 us | Approximately 12 us | 15 | 1 + SAMPDUR
223223
224224
`*` The default samplen given above is the default that the core sets it to when the ADC is initialized. The hardware defaults to 0, giving a much shorter sampling time. Also, as shown above while it's called SAMPLEN on parts with that don't have the PGA, with the new ADC and accompanying register name reshuffle, that became SAMPDUR. SAMPLEN was the sole bitfienld in the SAMPCTRL on Dx, while SAMPDUR is the sole bitfield on the clearly named CTRLE register. I'm not sure how either of those differences made it through. If I were in the room at the time, I'd have let 'em have it, because you should never rename a register without good reason, and the renamed register should never be objectively worse than the previous one. In this case, there is no conceivable good reason, and the new register name (CTRLE I mean) is obviously worse, since it gives no indication of it's function, nor is it even located immediately after CTRLD.
225225
@@ -228,12 +228,12 @@ On the 2-series, we are at least given some numbers: 8pF for the sample and hold
228228
### (mTC/DxC) analogReadEnh(pin, res=ADC_NATIVE_RESOLUTION, gain=0)
229229
Enhanced `analogRead()` - Perform a single-ended read on the specified pin. `res` is resolution in bits, which may range from 8 to `ADC_MAX_OVERSAMPLED_RESOLUTION`. This maximum is 13 bits for 0/1-series parts, and 17 for 2-series. If this is less than the native ADC resolution, that resolution is used, and then it is right-shifted 1, 2, or 3 times; if it is more than the native resolution, the accumulation option which will take 4<sup>n</sup> samples (where `n` is `res` native resolution) is selected. Note that maximum sample burst reads are not instantaneous, and in the most extreme cases can take milliseconds. Depending on the nature of the signal - or the realtime demands of your application - the time required for all those samples may limit the resolution that is acceptable. The accumulated result is then decimated (rightshifted n places) to yield a result with the requested resolution, which is returned. See [Atmel app note AVR121](https://ww1.microchip.com/downloads/en/appnotes/doc8003.pdf) - the specific case of the new ADC on the Ex and tinyAVR 2-series is discussed in the newer DS40002200 from Microchip, but it is a rather vapid document). Alternately, to get the raw accumulated ADC readings, pass one of the `ADC_ACC_n` constants for the second argument where `n` is a power of 2 up to 64 (0/1-series), or up to 1024 (2-series). Be aware that the lowest bits of a raw accumulated reading should not be trusted.; they're noise, not data (which is why the decimation step is needed, and why 4x the samples are required for every extra bit of resolution instead of 2x). On 2-series parts *the PGA can be used for single ended measurements*. Valid options for gain on the 2-series are 0 (PGA disabled, default), 1 (unity gain - may be appropriate under some circumstances, though I don't know what those are), or powers of 2 up to 16 (for 2x to 16x gain). On AVR Dx and tinyAVR 0/1-series parts, the gain argument should be omitted or 0; these do not have a PGA.
230230
231-
| Part Series | Max Acc. | result trunc? | Maximum acc+decimate | Max PGA gain |
232-
|-------------|--------------|-----------------|----------------------|---------------|
233-
| 0/1-series | 64 samples | N/A | 13 bits | N/A - no PGA |
234-
| Dx-series | 128 samples | 16 bits max | 15 bits | N/A - no PGA |
235-
| 2-series | 1024 samples | No | 17 bits | 0/1/2/4/8/16x |
236-
| EA-series | 1024 samples | No | 17 bits | 0/1/2/4/8/16x |
231+
| Part Series | Max Acc. | result trunc? | Maximum acc+decimate | Max PGA gain
232+
|-------------|--------------|-----------------|----------------------|---------------
233+
| 0/1-series | 64 samples | N/A | 13 bits | N/A - no PGA
234+
| Dx-series | 128 samples | 16 bits max | 15 bits | N/A - no PGA
235+
| 2-series | 1024 samples | No | 17 bits | 0/1/2/4/8/16x
236+
| EA-series | 1024 samples | No | 17 bits | 0/1/2/4/8/16x
237237
238238
**WARNING** trying to take 17-bit readings on a 2-series/EA-series will take a long time for each sample. If the sample is changing, the results will be garbage.
239239
**WARNING** Extreme attention is required to make the least significant bits meaningful, especially when oversampling and decimating to 17 bits. This means very careful hardware design. Otherwise, you will be very accurately measuring the noise and error sources. I am praying that the EA-series will have AVDD on a separate power domain and invite us to filter it further to improve analog stability. In any event, quality external ADC reference is recommended when high accuracy is required.
@@ -271,16 +271,16 @@ This, again, is easy to distinguish from an error code, as the error codes are c
271271
### (mTC/DxC) analogClockSpeed(int16_t frequency = 0, uint8_t options = 0)
272272
The accepted options for frequency are -1 (reset ADC clock to core default, 1-1.35 MHz), 0 (make no changes - just report current frequency) or a frequency, in kHz, to set the ADC clock to.
273273

274-
| Part series | F_ADCmin | F_ADCmax | Reference | Prescalers |
275-
|-------------|----------|----------|-----------|-----------------------------|
276-
| tinyAVR 0/1 | 100 | 250 | 0.55V | 8 from 2 to 256 |
277-
| tinyAVR 0/1 | 200 | 1500 | All other | 8 from 2 to 256 |
278-
| tinyAVR 0/1 | 200 | 2000 | Not 0.55V | Must use 8-bit resolution |
279-
| tinyAVR 2 | 300 | 6000 | Internal | 16 from 2 to 64 |
280-
| tinyAVR 2 | 300 | 6000 | External | 16 from 2 to 64 |
281-
| AVR Dx | 125 | 2000 | All | 14 from 2 to 256 |
282-
| AVR EA | 300 | 3000 | Internal | 16 from 2 to 64 |
283-
| AVR EA | 300 | 6000 | External | 16 from 2 to 64 |
274+
| Part series | F_ADCmin | F_ADCmax | Reference | Prescalers
275+
|-------------|----------|----------|-----------|-----------------------------
276+
| tinyAVR 0/1 | 100 | 250 | 0.55V | 8 from 2 to 256
277+
| tinyAVR 0/1 | 200 | 1500 | All other | 8 from 2 to 256
278+
| tinyAVR 0/1 | 200 | 2000 | Not 0.55V | Must use 8-bit resolution
279+
| tinyAVR 2 | 300 | 6000 | Internal | 16 from 2 to 64
280+
| tinyAVR 2 | 300 | 6000 | External | 16 from 2 to 64
281+
| AVR Dx | 125 | 2000 | All | 14 from 2 to 256
282+
| AVR EA | 300 | 3000 | Internal | 16 from 2 to 64
283+
| AVR EA | 300 | 6000 | External | 16 from 2 to 64
284284

285285
Values between 125 and 2000 are considered valid for Dx-series parts and Ex-series parts 300-3000 with internal reference, and 300-6000 with Vdd or external reference. The prescaler options are discrete, not continuous, so there are a limited number of possible settings (the fastest and slowest of which are often outside the rated operating range). The core will choose the highest frequency which is within spec, and which does not exceed the value you requested.
286286

0 commit comments

Comments
 (0)