Forum Rule: Always post complete source code & details to reproduce any issue!
-
Teensy LC analogRead -- seems to be limited to 10-bits?
I have some code to read signals from a scientific instrument. It clips at a tad under 3 volts, so I would expect my highest readings using analogRead to be nearly full-scale (so the better part of 4095-ish for 12 bits, the better part of 65535-ish for 16 bits etc.). Instead, I am getting max readings in the high 860s (so, the better part of 10 bits).
So, I hooked the analog line up to the 3.3 volt ref, and, sure-enough, I got readings of 1023.
The literature for the Teensy says it has a 16 bit A/D that is good to 12 bits of precision. Is there a way to enable this? In my application, I would be grateful for the added precision.
Did some poking around, but did not turn up any posts that addressed this.
Thanks
-
Found the ADC library, which revealed all.
I did find that the ADC library did not compile cleanly for me (error lin line 108 of RingBufferDMA.cpp), and I added the following to the beginning of RingBufferDMA.cpp to hack my way around the compile error
#ifndef DMAMUX_SOURCE_ADC1
#define DMAMUX_SOURCE_ADC1 -1
#endif
The cleaner fix, of course, would be to put conditional compilation #defines around all such bits of code ... but I am in a hurry
.
-
Senior Member

Originally Posted by
pezman
The literature for the Teensy says it has a 16 bit A/D that is good to 12 bits of precision. Is there a way to enable this?
analogReadResolution(12);
The default is 10, for compatibility with Arduino.
-
And if you're using the ADC library, get the latest version. It should compile with no errors or warnings.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules