Rivian Irvine Team
/
TCTF_Control_Main
Control Code with I/O and ADC working
Diff: LTC2487/LTC2487.cpp
- Revision:
- 2:bd118a724f03
- Parent:
- 1:0182b86f9bd4
- Child:
- 5:0f38a0bd4f86
diff -r 0182b86f9bd4 -r bd118a724f03 LTC2487/LTC2487.cpp --- a/LTC2487/LTC2487.cpp Mon Feb 05 06:41:23 2018 +0000 +++ b/LTC2487/LTC2487.cpp Thu Feb 08 23:10:52 2018 +0000 @@ -53,14 +53,14 @@ //send message to select channel i2c.write((addrI2C<<1)|(I2C_WRITE), ADC_channel, 1); //must wait, otherwise breaks... - wait(0.2); - //send configuration (1 gain, autocalibration + wait(0.1); + //send configuration (1 gain, autocalibration) i2c.write((addrI2C<<1)|(I2C_WRITE), ADC_config, 1); //must wait, otherwise breaks... - wait(0.2); + wait(0.1); //Read data from selected channel --> 24bits --> 23bit=SIGN 22bit=MSB 21-7bits=DATA 5-0bits=JUNK - i2c.read((addrI2C<<1)|(I2C_READ), ADC_data_rx, 3); - //Stich togethor the bytes into a 24bit value + i2c.read((addrI2C<<1)|(I2C_READ), ADC_data_rx, 3); + //Stitch together the bytes into a 24bit value unsigned long data = (ADC_data_rx[0] << 16) | (ADC_data_rx[1] << 8)| ADC_data_rx[2]; //Delete SIGN bit and MSB bit and remove 6 JUNK bits unsigned long ADC_Result = (data&0x3fffff)>>6;