Other Parts Discussed in Thread: FDC2214
I try to read the FDC2214 bricked out from the EVM with my Arduino MKRZero (runs on 3V).
Unfortunately I only receive "0"s for each channel. I also checked the errors, and the INTB pin is randomly high, when I then read out the status register it is always 0 on each bit. I noticed when I touch one of the copper plates I use as sensor plates, INTB never goes high anymore.
For the configuration I mainly followed the example in the datasheet.
Any help would be great!
Here is my code:
#include <Wire.h> // Pin definitions const byte INT_PIN = 9; const byte ADR_PIN = 10; const byte SDA_PIN = 11; const byte SCL_PIN = 12; // registers const byte FDC = 0x2A; // FDC address ADR_PIN=LOW: 0x2A; ADR_PIN=HIGH: 0x2B; const byte CH0MSB = 0x00; // Most significant bits of the conversion result on channel 0. [11:0]-->>[27:16] const byte CH0LSB = 0x01; // Less significant bits of the conversion result on channel 0. [15:0]-->>[15:0] const byte CH1MSB = 0x02; const byte CH1LSB = 0x03; const byte CH2MSB = 0x04; const byte CH2LSB = 0x05; const byte CH3MSB = 0x06; const byte CH3LSB = 0x07; const byte ERR = 0x18; // Configuring the FDC2214 void writeConfig(byte FDC_addr, byte reg, byte MSB, byte LSB) { Wire.beginTransmission(FDC_addr); Wire.write(reg); Wire.write(MSB); Wire.write(LSB); Wire.endTransmission(); } // Set the parameters for the I2C void Configuration(byte FDC_addr) { // Sensor frequency writeConfig(FDC_addr, 0x14, 0x20, 0x02); writeConfig(FDC_addr, 0x15, 0x20, 0x02); writeConfig(FDC_addr, 0x16, 0x20, 0x02); writeConfig(FDC_addr, 0x17, 0x20, 0x02); // Sensor drive current // Does not matter when 0x1A[11] is set to 0. (It is) writeConfig(FDC_addr, 0x1E, 0x7C, 0x00); writeConfig(FDC_addr, 0x1F, 0x7C, 0x00); writeConfig(FDC_addr, 0x20, 0x7C, 0x00); writeConfig(FDC_addr, 0x21, 0x7C, 0x00); // Settling time writeConfig(FDC_addr, 0x10, 0x00, 0x0A); writeConfig(FDC_addr, 0x11, 0x00, 0x0A); writeConfig(FDC_addr, 0x12, 0x00, 0x0A); writeConfig(FDC_addr, 0x13, 0x00, 0x0A); // Conversion time writeConfig(FDC_addr, 0x08, 0x83, 0x29); writeConfig(FDC_addr, 0x09, 0x83, 0x29); writeConfig(FDC_addr, 0x0A, 0x83, 0x29); writeConfig(FDC_addr, 0x0B, 0x83, 0x29); // Error config writeConfig(FDC_addr, 0x19, 0x38, 0x11); // No errors will be reported // MUX_CONFIG, here is set how many channels are used writeConfig(FDC_addr, 0x1B, 0xC2, 0x0D); // General config // Needs to be set last, activates the sensor writeConfig(FDC_addr, 0x1A, 0x16, 0x01); // external clock with 40 Mhz } void setup() { Wire.begin(); Serial.begin(9600); Serial.println("Starting"); // Set name and settings of FDC pinMode(ADR_PIN, OUTPUT); pinMode(INT_PIN, INPUT); digitalWrite(ADR_PIN, LOW); Configuration(FDC); } void loop() { Wire.beginTransmission(FDC); monitor(); delay(10); } // Build the complete conversion result from the specific channel (0?) unsigned long readChannel(byte FDC_addr, int chan) { unsigned long val = 0; word c = 0; word d = 0; if(chan == 0) { c = readValue(FDC_addr, CH0MSB); d = readValue(FDC_addr, CH0LSB); } else if(chan == 1) { c = readValue(FDC_addr, CH1MSB); d = readValue(FDC_addr, CH1LSB); } else if(chan == 2) { c = readValue(FDC_addr, CH2MSB); d = readValue(FDC_addr, CH2LSB); } else if(chan == 3) { c = readValue(FDC_addr, CH3MSB); d = readValue(FDC_addr, CH3LSB); } val = c; val <<= 16; val += d; return val; } // Read bytes from register channel specified word readValue(byte FDC_addr, byte reg) { byte a = 0; byte b = 0; word value = 0; Wire.beginTransmission(FDC_addr); Wire.write(reg); Wire.endTransmission(); Wire.requestFrom(FDC_addr, 2); while(Wire.available()) { a = Wire.read(); b = Wire.read(); } value = a; value <<= 8; value += b; return value; } void monitor() { checkError(); long current0 = readChannel(FDC, 0); long current1 = readChannel(FDC, 1); long current2 = readChannel(FDC, 2); long current3 = readChannel(FDC, 3); Serial.print(current0); Serial.print("\t"); Serial.print(current1); Serial.print("\t"); Serial.print(current2); Serial.print("\t"); Serial.println(current3); } void checkError(){ int error = digitalRead(INT_PIN); if(error == 0){ Serial.print("Error detected! "); byte error_msg = readValue(FDC, ERR); Serial.println(error_msg, HEX); } }