Hi,
I am trying to interface ADS7828 to the Teensy 4.0 development board via I2C with no success. I read PJRC website article about Wire library which uses teensy to eprom with no avail. In the code below, simply I am trying to read(pot) channel 0 single-ended by first write the address byte and the command byte, afterwards reading Highbyte and the Low byte, which then by code gives a 12bit reading of the potentiometer. Kindly can someone help me on this, your help is much appreciated.
#include <Wire.h>
void setup() {
Serial.begin(9600);
Wire.begin();
}
void loop()
{
Wire.beginTransmission(90);//address byte slave address 0 0
Wire.send(132);//command byte reading channel 0 single-ended, external reference
Wire.endTransmission();
Wire.requestFrom(90,2);//address byte, then wait to read two consecutive bytes
while(Wire.available()==0);
int highbyte1=Wire.receive();
int lowbyte1=Wire.receive();
int a=highbyte1<<8;
int pot_1=a|lowbyte1;// adapting the high byte and the low byte to calculate 12bit reading
Serial.println(pot_1);//12 bit reading
Wire.end();
delay(500);
}
I am trying to interface ADS7828 to the Teensy 4.0 development board via I2C with no success. I read PJRC website article about Wire library which uses teensy to eprom with no avail. In the code below, simply I am trying to read(pot) channel 0 single-ended by first write the address byte and the command byte, afterwards reading Highbyte and the Low byte, which then by code gives a 12bit reading of the potentiometer. Kindly can someone help me on this, your help is much appreciated.
#include <Wire.h>
void setup() {
Serial.begin(9600);
Wire.begin();
}
void loop()
{
Wire.beginTransmission(90);//address byte slave address 0 0
Wire.send(132);//command byte reading channel 0 single-ended, external reference
Wire.endTransmission();
Wire.requestFrom(90,2);//address byte, then wait to read two consecutive bytes
while(Wire.available()==0);
int highbyte1=Wire.receive();
int lowbyte1=Wire.receive();
int a=highbyte1<<8;
int pot_1=a|lowbyte1;// adapting the high byte and the low byte to calculate 12bit reading
Serial.println(pot_1);//12 bit reading
Wire.end();
delay(500);
}