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: UNABLE TO READ THE TDC7200 REGISTERS PROPERLY

Part Number: TDC7200

Hi,

I'm working on Time of Flight measurements using TDC7200 and PIC 18F4550. However, whenever i read back the 24 bit registers the MSB is received as 0. Also when i read back he configuration without providing the TDC with start and stop pulses, i get back origina values( 0x03 for CONFIG1) and after start stop pulses are provided, CONFIG1 is read as 0x02 (same in a loop). 

  • Hello,

    Can you please post some scope captures of the SPI communication lines during the improper transactions? What are the SPI settings being used, and do you have an example of some of the SPI transaction code that you are using?

    Thanks,
  • Here's the code we're using for SPI transaction. We have used functions for reading and writing the 8 and 24 bit registers. We shall post the scope captures as soon as possible.

    setupSPI()
    
    {
    
    
        TRISBbits.RB0 = 1;					 // SDI configured as input
        TRISBbits.RB1 = 0;					 // SCLK configured as output
        TRISCbits.RC7 = 0;					 // SDO configured as output
        TRISCbits.RD6 = 0;					 // Slave select
    
        //SPI configuration
    
        SSPSTAT= 0b11000000;
        SSPCON1 =0b00100010;
    
    }
    
    
    enableSPI()
    
    {
    
    SSPCON1bits.SSPEN = 1; //activate SPI related pins
    
    }
    
    
    disableSPI()
    
    {
    
    SSPCON1bits.SSPEN = 0; //disable SPI pins
    
    }
    
    
    
    void SPIWrite(int value)
    
    {
    
    PIR1bits.SSPIF=0;
    
    SSPBUF=value;
    
    while(!PIR1bits.SSPIF);
    
    PIR1bits.SSPIF=0;
    
    
    }
    
    
    unsigned char SPIRead8(int address)
    
    {
    
    RD6=0;
    
    unsigned char data;
    
    SSPBUF=(address & 0x1F);
    
    while(!PIR1bits.SSPIF);
    
    PIR1bits.SSPIF=0;
    
    SSPBUF=0x00;
    
    while(!PIR1bits.SSPIF);
    
    data=SSPBUF;
    
    PIR1bits.SSPIF=0;
    
    RD6=1;
    
    return data;
    
    }
    
    
    
    void SPIRead24(int address,unsigned char *a,unsigned char *b,unsigned char *c)
    {
        RD6=0;
        PIR1bits.SSPIF=0;
        SSPBUF=(address & 0x1F);
        while(!PIR1bits.SSPIF);
        PIR1bits.SSPIF=0;
        SSPBUF=0x00;
        while(!PIR1bits.SSPIF);
        PIR1bits.SSPIF=0;
        *a = SSPBUF;
        SSPBUF=0x00;
        while(!PIR1bits.SSPIF);
        PIR1bits.SSPIF=0;
        *b = SSPBUF;
        SSPBUF=0x00;
        while(!PIR1bits.SSPIF);
        PIR1bits.SSPIF=0;
        *c = SSPBUF;
        RD6=1;
    }
    
    
    
    void main()
    
    {
    
    
    unsigned int counter=0;
    
    unsigned char lower=0x00;
    
    unsigned char upper=0x00;
    
    unsigned char a,b,c;
    
    unsigned char config1,config2;
    
    unsigned char array[15];
    
    
    	TRISBbits.RD7 = 0;					// Enable
    	TRISBbits.RB2 = 1;					//Interrupt pin
    
    	TRISD=0;
    	PORTD=0;
        
        const int CONFIG1 = 0x00;           		// default 0x00
        const int CONFIG2 = 0x01;           		// default 0x40
        const int INT_STATUS = 0x02;        		// default 0x00
        const int INT_MASK = 0x03;           		// default 0x07
        const int COARSE_CNTR_OVF_H = 0x04;        // default 0xff
        const int COARSE_CNTR_OVF_L = 0x05;        // default 0xff
        const int CLOCK_CNTR_OVF_H = 0x06;         // default 0xff
        const int CLOCK_CNTR_OVF_L = 0x07;         // default 0xff
        const int CLOCK_CNTR_STOP_MASK_H = 0x08;   // default 0x00
        const int CLOCK_CNTR_STOP_MASK_L = 0x09;   // default 0x00
        
        const int TIME1 = 0x10;           		// default 0x00_0000
        const int CLOCK_COUNT1 = 0x11;             // default 0x00_0000
        const int TIME2 = 0x12;           		// default 0x00_0000
        const int CLOCK_COUNT2 = 0x13;             // default 0x00_0000
        const int TIME3 = 0x14;           		// default 0x00_0000
        const int CLOCK_COUNT3 = 0x15;             // default 0x00_0000
        const int TIME4 = 0x16;           		// default 0x00_0000
        const int CLOCK_COUNT4 = 0x17;             // default 0x00_0000
        const int TIME5 = 0x18;           		// default 0x00_0000
        const int CLOCK_COUNT5 = 0x19;             // default 0x00_0000
        const int TIME6 = 0x1A;           		// default 0x00_0000
        const int CALIBRATION1 = 0x1B;             // default 0x00_0000
        const int CALIBRATION2 = 0x1C;             // default 0x00_0000
        
        delay(2);
        RD7=0;
        delay(5);
        RD7=1;
    
    
    	config1=0x03;
    	config2=0x40;
    
    
    while(1)
    {               
        
    	setupSPI();
    	enableSPI();
    
    	RD6=0;
    	SPIWrite(CONFIG1 | 0x03); //configure for MODE 2 measurement
    	SPIWrite(config1);
    	RD6=1;
    
    	for(int n=0;n<5;n++);
    
    	RD6=0;
    	SPIWrite(CONFIG2 | 0x40); //configure for single stop 
    	SPIWrite(config2);
    	RD6=1;
    
    //reading back configuration registers
    config1=SPIRead8(CONFIG1); 
    
    config2=SPIRead8(CONFIG2);
    
    
    while(INT);
    
    delay(2);
    
    
    SPIRead24(TIME1,&a,&b,&c);
    
    array[0]=a;
    
    array[1]=b;
    
    array[2]=c;
    
    
    SPIRead24(TIME2,&a,&b,&c);
    
    array[3]=a;
    
    array[4]=b;
    
    array[5]=c;
    
    
    SPIRead24(CLOCK_COUNT1,&a,&b,&c);
    
    array[6]=a;
    
    array[7]=b;
    
    array[8]=c;
    
    
    SPIRead24(CALIBRATION1,&a,&b,&c);
    
    array[9]=a;
    
    array[10]=b;
    
    array[11]=c;
    
    
    SPIRead24(CALIBRATION2,&a,&b,&c);
    
    array[12]=a;
    
    array[13]=b;
    
    array[14]=c;
    
    
    
    disableSPI();
    
    
    
    
     
    }
    
    }