Abadi alali
Active member
Hello,
I am using the ADC_0 in the teensy 3.6 as follows:
this is just the initialization part of the code I am using the Pdb and everything works but I am not getting the resolution I expect to get and I get a high error. I have been testing the code with DC voltage and it looks like I have a resolution much less than 12 Bits.
I get this output when I am putting 508 mV DC into pin A9 (my adc input pin)
is this a normal output or am I doing something wrong?
I am using the ADC_0 in the teensy 3.6 as follows:
Code:
std::array<volatile uint16_t, 4096> buffer1;
volatile size_t write_pos1 = 0;
\\the setup
void setup() {
adc.adc0->setAveraging(1);
adc.adc0->setResolution(12);
adc.adc0->setConversionSpeed(ADC_CONVERSION_SPEED::HIGH_SPEED);
adc.adc0->setSamplingSpeed(ADC_SAMPLING_SPEED::HIGH_SPEED);
adc.adc0->analogRead(adc_pin0); // performs various ADC setup stuff
adc.setReference(ADC_REFERENCE::REF_3V3, ADC_0);
adc.enableInterrupts(ADC_0);
}
\\ the read part
void adc0_isr() {
if (write_pos1 <= 1025) {
// Serial.println(write_pos1);
size_t write_pos_ = write_pos1;
buffer1[write_pos_] = adc.adc0->readSingle();
write_pos_++;
if (write_pos_ >= buffer1.size()) write_pos_ = 0;
write_pos1 = write_pos_;
}
if (write_pos1 == 1026)
{
// Serial.println(" Stopping PDB");
stopPdb();
noInterrupts();
write_pos1 = 0;
write_pos2 = 0;
reading = false;
//
}
}
this is just the initialization part of the code I am using the Pdb and everything works but I am not getting the resolution I expect to get and I get a high error. I have been testing the code with DC voltage and it looks like I have a resolution much less than 12 Bits.
I get this output when I am putting 508 mV DC into pin A9 (my adc input pin)
is this a normal output or am I doing something wrong?