![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Control Code with I/O and ADC working
Diff: LTC2487/LTC2487.cpp
- Revision:
- 13:604e6933366f
- Parent:
- 12:1cada1fe4743
- Child:
- 14:69cd53434783
diff -r 1cada1fe4743 -r 604e6933366f LTC2487/LTC2487.cpp --- a/LTC2487/LTC2487.cpp Mon May 07 03:38:15 2018 +0000 +++ b/LTC2487/LTC2487.cpp Tue May 08 17:08:37 2018 +0000 @@ -42,6 +42,7 @@ char ADC_data_rx[3]; char ADC_config[1]; ADC_config[0] = 0b10001000;//0x82; //0b10000010 + char cmd[2]; //select channel to read switch (chnl){ @@ -59,13 +60,18 @@ break; } - //send message to select channel + cmd[0] = ADC_channel[0]; + cmd[1] = ADC_config[0]; + + i2c.write((addrI2C<<1)|(I2C_WRITE), cmd, 2); + + /*//send message to select channel i2c.write((addrI2C<<1)|(I2C_WRITE), ADC_channel, 1); //must wait, otherwise breaks... wait(0.08); //send configuration (1 gain, autocalibration) i2c.write((addrI2C<<1)|(I2C_WRITE), ADC_config, 1); - //must wait, otherwise breaks... + //must wait, otherwise breaks...*/ wait(0.08); //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);