The TI E2E™ design support forums will undergo maintenance from Sept. 28 to Oct. 2. If you need design support during this time, contact your TI representative or open a new support request with our customer support center.

This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TDC7200: Reading and writing to TDC7200 with Arduino

Part Number: TDC7200
Other Parts Discussed in Thread: TDC1000,

Hello,

I am currently facing some troubles regarding the reading/writing to my TDC7200 with my Arduino Uno. I have tried circuits below with and without pullup resistors, and included the code I used below. For both circuits, I am able to read/write to my TDC1000 just fine, but for some reason I am unable to do the same for the TDC7200. Are the SPI conventions different between these two ICs?

Do let me know if I can provide for information that would provide more insight. Thank you for your time and attention.


Regards,

Jack

Connections:

#include <SPI.h>
#include <stdint.h>

int dt = 200;
float CLK_FREQ = 8*pow(10,6);//CLOCK frequency (default 8MHz)
float CLK_PERIOD = 1/CLK_FREQ;
uint32_t SPIfrequency = 20000000;

//*******************************TDC7200 REGISTER ADDRESS LIST*****************************

byte CONFIG1 = 0x00;
byte CONFIG2 = 0x01;
byte INT_STATUS =0x02;
byte INT_MASK = 0x03;
byte COARSE_CNTR_OVF_H = 0x04;
byte COARSE_CNTR_OVF_L = 0x05;
byte CLOCK_CNTR_OVF_H = 0x06;
byte CLOCK_CNTR_OVF_L = 0x07;
byte CLOCK_CNTR_STOP_MASK_H = 0x08;
byte CLOCK_CNTR_STOP_MASK_L = 0x09;

byte TIME1 = 0x10;
byte CLOCK_COUNT1 = 0x11;
byte TIME2 = 0x12;
byte CALIBRATION1 = 0x1B;
byte CALIBRATION2 = 0x1C;
//***************************END OF TDC7200 REGISTER ADDRESS LIST**************************

int selectTDC1000 = 5;
int selectTDC7200 = 6;
int enableTDC1000 = 7;
int enableTDC7200 = 8;
int dataReadyPin = 4;
int channelSelect = 3;
int INTBTDC7200 = 2;
int TDC7200clock = 9;


void setup() {
   Serial.begin(9600);
  Serial.println("----------------------Program Start-------------------------");
  SPI.begin();
  pinMode(TDC7200clock,OUTPUT);
  pinMode(selectTDC1000, OUTPUT);
  pinMode(selectTDC7200, OUTPUT);
  pinMode(enableTDC1000, OUTPUT);
  pinMode(enableTDC7200, OUTPUT);
  pinMode(dataReadyPin, INPUT); //Unused in loops
  pinMode(channelSelect, OUTPUT); //Unused in loops
  analogWrite(TDC7200clock, 128);
  digitalWrite(selectTDC1000, HIGH);
  digitalWrite(selectTDC7200, HIGH); //Select is Active low, set to high @ initialise
  digitalWrite(enableTDC1000, LOW);
  digitalWrite(enableTDC7200, LOW); //Enable is Active high, set to low @ initialise
  digitalWrite(enableTDC1000, HIGH);
  digitalWrite(enableTDC7200, HIGH);
  delay(dt);


TDC7200Write(CONFIG1,0x02);
TDC7200Write(CONFIG2,0x80);
TDC7200Write(INT_STATUS,0x06);
TDC7200Write(INT_MASK,0x89);

uint16_t readCONFIG1 = TDC7200Read(CONFIG1);
uint16_t readCONFIG2 = TDC7200Read(CONFIG2);
uint16_t readINT_STATUS = TDC7200Read(INT_STATUS);
uint16_t readINT_MASK = TDC7200Read(INT_MASK);

  Serial.print("CONFIG1= ");
  Serial.println(readCONFIG1,BIN);
  Serial.print("\n");
  Serial.print("CONFIG2= ");
  Serial.println(readCONFIG2,BIN);
  Serial.print("\n");
  Serial.print("INT_STATUS= ");
  Serial.println(readINT_STATUS,BIN);
  Serial.print("\n");
  Serial.print("INT_MASK= ");
  Serial.println(readINT_MASK,BIN);
  Serial.print("\n");
}

void loop() {
  // put your main code here, to run repeatedly:
  SPI.beginTransaction(SPISettings(SPIfrequency,MSBFIRST,SPI_MODE3));
  delay(1000);
}

void TDC7200Write(byte address,byte data){
  SPI.beginTransaction(SPISettings(SPIfrequency,MSBFIRST,SPI_MODE3));
  digitalWrite(selectTDC7200, LOW);//between selectTDC1000 OR selectTDC7200
  delayMicroseconds(100);
  address |= 0x40;
  SPI.transfer(address);
  SPI.transfer(data);
  digitalWrite(selectTDC7200, HIGH);
  SPI.endTransaction();
  };


byte TDC7200Read(byte address){
  SPI.beginTransaction(SPISettings(SPIfrequency,MSBFIRST,SPI_MODE3));
  digitalWrite(selectTDC7200, LOW);
  delayMicroseconds(100);
  //SPI.transfer(address);
  SPI.transfer(address);
  byte inByte = SPI.transfer(0x00);
  digitalWrite(selectTDC7200, HIGH);
  SPI.endTransaction();
  return inByte;
  };

EXAMPLE OUTPUT:

When R/W to TDC7200:

----------------------Program Start-------------------------

CONFIG1= 11111111

CONFIG2= 11111111


INT_STATUS= 11111111

INT_MASK= 11111111

When R/W to TDC1000:

----------------------Program Start-------------------------

CONFIG_0= 10

CONFIG_1= 10000000


CONFIG_2= 110

CONFIG_3= 1001

  • Hi Jack,

    Are you able to read the default TDC7200 register values (reset values) before performing any writes?

    If you have a scope, have a look at the 4 SPI lines during operation and also make sure the TDC1000 CS is low. 

    Hardware considerations:

    - pull up resistors are not needed here

    - make the SPI lines as short as possible

    Regards,

    Gabriel

  • Hello Gabriel,

    Thank you for the advice, and taking the time.

    I am unable to read the default values from the TDC7200 (The read values always appear as '0'). I attempted to pull the enable pin to low, then back to high in order to reset the device.

    I have a scope, but I only have 3 probes at the moment. I performed tests for the TDC7200 and TDC1000, and have some screencaps to share:

    Testing CS pins for both ICs. Both CS pins are individually pulled high low for 4 write and 4 read commands.

    BLUE = TDC1000 CS                        RED = TDC7200 CS

    TDC1000: Writing the program values. The values read/written to the 4 registers above are as expected.

    BLUE = DOUT                      RED = DIN                 GREEN = CS 1000

    I also tried R/W-ing 0xFF to the registers to the TDC1000. All 4 registers read '1111 1111'

    BLUE = DOUT                      RED = DIN                 GREEN = CS 1000

    Here's the R/W for TDC7200. Namely, I don't see the same spike at the end of the eight CS pulses.

    BLUE = DOUT                      RED = DIN                 GREEN = CS7200

    Hope this provides some information to why I may be facing this issue. Thank you once again for your time.

    Regards,

    Jack

  • Hi Jack,

    Could you please clarify what data the uno is sending in the second plot? 

    It would be easier to see what's going on if you can adjust the vertical scale and plot in this format:

    Try capturing the CS, SCK and SDI/SDO lines for the command field (send address) and for the data field in separate plots. 

    It looked to me that your CS is being pulsed during the R/W operation? It should look like the example above. 

    Regards,

    Gabriel

  • Hello Gabriel,

    For the previous images, I had set the SPI frequency too high and the scope sampling rate too low. Please ignore them. I've used a lower SPI frequency and higher sampling rate to get plots in the above format.

    I have 1 read and 1 write for each TDC1000 and TDC7200.

    SPI Frequency = 250kHz

    Register address R/W to = 0x02 (B0000 0010)

    Data Written/expected to be read = 0x06 (B0000 0110)

    BLUE = DOUT          RED = DIN     GREEN = SCLK         YELLOW = CS

    Write TDC1000

    TDC1000 read

    TDC7200 write

    TDC7200 read

    I can still read the written value for TDC1000 (Read value = 0x06), but not for the TDC7200(Read value = 0).It seems that the Arduino is writing correctly to the ICs, and the CS is being set to LOW at the correct windows. However, the TDC7200 DOUT does not return any values.

    I have used other TDC7200 ICs hoping it was an issue with the hardware, but to no avail.

    Hope this provides more insight. Thank you for your time so far.

    Regards,

    Jack

  • Hi Jack,

    Thank you for the new plots, now it is clear to see. 

    Testing the other TDC7200 tells us that at least it's not a device issue. Most likely then it's a board issue. 

    What is your hardware configuration? Do you have the TDC1000 and TDC7200 mounted on a PCB with the arduino connections made via breadboard, soldered wire connections, cables? Or is everything on a PCB? A clean hardware configuration is especially important when high speed communication is used. 

    Make sure the proper layout guidelines and recommendations were followed for the TDC1000 and TDC7200

    For both devices, source termination resistors are recommended (22 ohm), for more information please see this previous post. Bob gives some good advice with detailed explanations. 

    Regards,

    Gabriel

  • Hello Gabriel,

    Thank you for the help so far. I've managed to R/W to the TDC7200 on the EVM using the Arduino programme, by soldering some connections from the Arduino to the test points. However, I haven't found the same success in performing R/W to just the IC, so it's likely an issue with me making incorrect hardware connections.

    That being said, may I check If all the resistors and capacitors (C2/C4, R1-R6) present on the TDC7200EVM are necessary for the TDC7200 to function? The capacitors/resistors in question are from the TDC7200EVM, shown below:

    Do let me know if I should be starting a new thread to ask this question instead.

    Thank you for your time.

    Regards,

    Jack

  • Hi Jack,

    I'm glad you were able to narrow down the issue. 

    If you could please copy your new question over into a new thread, we would appreciate it, and I will post my answer there. 

    Thanks!

    Gabriel

  • Hello Gabriel,

    Sure I'll mark this thread as resolved and move the question to the other thread.

    Regards,

    Jack