NormalUser
Member
Hi All,
I am trying to to perform single reads on 3 different IOs on Teensy 4.0.
I got it working but only swapping the ADC peripherals, let me explain further more.
So, I am trying to use adc0 to read A0 and adc1 to read both A1 and A2.
The application only works when do this:
setup adcX->adc0
setup adcY->adc1
read adcValueX with adc1*
read adcValueY with adc0*
*notice how I swapped the adc peripheral reference to the setup.
Here is the code:
#include <ADC.h>
#include <ADC_util.h>
unsigned char adcValueX,
adcValueY[2];
ADC *adcX = new ADC();
ADC *adcY = new ADC ();
void setup() {
adcX->adc0->setReference(ADC_REFERENCE::REF_3V3);
adcX->adc0->setAveraging(16);
adcX->adc0->setResolution(8);
adcX->adc0->setConversionSpeed(ADC_CONVERSION_SPEED::MED_SPEED);
adcX->adc0->setSamplingSpeed(ADC_SAMPLING_SPEED::MED_SPEED);
adcY->adc1->setReference(ADC_REFERENCE::REF_3V3);
adcY->adc1->setAveraging(16);
adcY->adc1->setResolution(8);
adcY->adc1->setConversionSpeed(ADC_CONVERSION_SPEED::MED_SPEED);
adcY->adc1->setSamplingSpeed(ADC_SAMPLING_SPEED::MED_SPEED);
}
void loop() {
adcValueX = adcX->adc1->analogRead(A0);
adcValueY[0] = adcY->adc0->analogRead(A1);
adcValueY[1] = adcY->adc0->analogRead(A2);
Serial.print(adcValueX, DEC);
Serial.print(" ");
Serial.print(adcValueY[0], DEC);
Serial.print(" ");
Serial.println(adcValueY[1], DEC);
delay(500);
}
Maybe I am defining something wrong and any help or feedback will be highly appreciated.
I am concern this may be a bug and in a future Teensyduino release I will break my application.
Thanks to all,
Normal.User.
I am trying to to perform single reads on 3 different IOs on Teensy 4.0.
I got it working but only swapping the ADC peripherals, let me explain further more.
So, I am trying to use adc0 to read A0 and adc1 to read both A1 and A2.
The application only works when do this:
setup adcX->adc0
setup adcY->adc1
read adcValueX with adc1*
read adcValueY with adc0*
*notice how I swapped the adc peripheral reference to the setup.
Here is the code:
#include <ADC.h>
#include <ADC_util.h>
unsigned char adcValueX,
adcValueY[2];
ADC *adcX = new ADC();
ADC *adcY = new ADC ();
void setup() {
adcX->adc0->setReference(ADC_REFERENCE::REF_3V3);
adcX->adc0->setAveraging(16);
adcX->adc0->setResolution(8);
adcX->adc0->setConversionSpeed(ADC_CONVERSION_SPEED::MED_SPEED);
adcX->adc0->setSamplingSpeed(ADC_SAMPLING_SPEED::MED_SPEED);
adcY->adc1->setReference(ADC_REFERENCE::REF_3V3);
adcY->adc1->setAveraging(16);
adcY->adc1->setResolution(8);
adcY->adc1->setConversionSpeed(ADC_CONVERSION_SPEED::MED_SPEED);
adcY->adc1->setSamplingSpeed(ADC_SAMPLING_SPEED::MED_SPEED);
}
void loop() {
adcValueX = adcX->adc1->analogRead(A0);
adcValueY[0] = adcY->adc0->analogRead(A1);
adcValueY[1] = adcY->adc0->analogRead(A2);
Serial.print(adcValueX, DEC);
Serial.print(" ");
Serial.print(adcValueY[0], DEC);
Serial.print(" ");
Serial.println(adcValueY[1], DEC);
delay(500);
}
Maybe I am defining something wrong and any help or feedback will be highly appreciated.
I am concern this may be a bug and in a future Teensyduino release I will break my application.
Thanks to all,
Normal.User.