Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: Teensy LC analogRead -- seems to be limited to 10-bits?

  1. #1
    Junior Member
    Join Date
    Mar 2016
    Posts
    2

    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

  2. #2
    Junior Member
    Join Date
    Mar 2016
    Posts
    2
    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 .

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,228
    Quote Originally Posted by pezman View Post
    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.

  4. #4
    Senior Member+
    Join Date
    Jul 2013
    Posts
    294
    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
  •