Forum Rule: Always post complete source code & details to reproduce any issue!

1. Teensy 4 ADC hole of 7bits every 256 bit

Hello,

I'm using ADC on Teensy4. I read data on adc0 at 12bit resolution. Conseguently the readen integer range is 0-4095. I saw that every 256bit there's an hole in reading of 7bit. For example bit from 505 to 511 are missing. any help?

The same is at 10bit of resolution using pedvide adc library and arduino adc library.

2. Post some code which demonstrates the problem (and don't crosspost)

Pete

3. Hello Pete, sorry for the crosspost but I wasn't able to delete the first post.

Anyway for reproducing the problem you can put a DC signal of 413mV in A9 and run the following code.

I think the problem is Pedvide library but I'm not sure.

Code:
```#include <ADC.h>

long int sensorValue=0;

void setup() {
// put your setup code here, to run once:
Serial.begin(115200);

}
else{

}

}

void loop() {
// put your main code here, to run repeatedly:

}
else{

}

if(sensorValue==504){Serial.print(String("504")+"\n");} //si
if(sensorValue==505){Serial.print(String("505")+"\n");}
if(sensorValue==506){Serial.print(String("506")+"\n");}
if(sensorValue==507){Serial.print(String("507")+"\n");}
if(sensorValue==508){Serial.print(String("508")+"\n");}
if(sensorValue==509){Serial.print(String("509")+"\n");}
if(sensorValue==510){Serial.print(String("510")+"\n");}
if(sensorValue==511){Serial.print(String("511")+"\n");}
if(sensorValue==512){Serial.print(String("512")+"\n");} //si

delay(500);
//Serial.println(sensorValue);

}```

4. I put a 25k ohm potentiometer on A9 and your code prints values in the range 504 to 512 with ADCLibrary = 0 or 1.
Code:
```510
509
511
510
509
509
510
510
509
510
508
510
509
510
510
509
510
509
510```
What device do you have on A9?

Pete

5. What version of TeensyDuino is in use? TD 1.51 is the current version.

6. Remove the pinMode for readPin - it is not a digital input.

7. Hello Pete and the other hepled me. The versiono of TeensyDuino is 1.51 and Arduino 1.8.12. I simply connect a dc signal generator to A9 and GND. All oter pins are disconnected. I've tried to use only the arduino laibrary in e separated sketch and is working fine. In the evening I'll post oter tests and I'll use the potentiometer as well to make all reproducible.

pinMode(23, INPUT_DISABLE);

Does it help?

9. My previous test was done on a T3.2 - my bad, sorry.

I've now repeated the test using a T4 and a 10-turn 1k trimpot.
With the Arduino code, I can get values from 504 to 512 but with Pedvide it will only infrequently print 504 or 512 but nothing in between. Without touching the trimpot, I can switch back and forth between Arduino and Pedvide and it reliably shows values such as 505,506,507 for Arduino and between 497 and 500 for Pedvide.
It does exactly the same thing if I switch conversion and sampling speeds to LOW_SPEED.

Pete

10. Hello Pete and Paul,

I just do the test using a 25K potentiometer to divide the 3.3V. I can confirm that if I use Arduino library I can detect values from 504 to 512. If I use Pedvide Library I can detect only 504 and 512. Pete can you confirm what I saw?

pinMode(23, INPUT_DISABLE); don't helped me.

Anyway in the mean time I'll use Arduino Library because some micros of time of conversion aren't critical. I didn't saw the same problem on T3.6 but I've to repeat tests because I don't remember exactly.

11. @Lapasuc
Yes, that's what I saw.

Pete

12. @el_supremo

Do you think I've to write an issue in pedvide/ADC GIT hub?

13. Yes you can probably generate an issue up on his github project.

If it were me, I might try playing around with some of your settings to see if it makes a difference:
Code:
```adc->adc0->setAveraging(0);