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.

TDC7201-ZAX-EVM: SPI Communication STM32F334 (Master) -> TDC7201 (Slave)

Part Number: TDC7201-ZAX-EVM
Other Parts Discussed in Thread: TDC7201, MSP430G2553

Hello, I am trying to configure the  TDC1 of TDC7201 on the ZAX EVM Board with STM32F334 controller via SPI protocol.

I believe i have configured everything as explained in the Datasheet. I am still receiving 0x00 from the registers i wrote to. 

Does anyone have any idea why this is happening?

1) Set Enable PIN.

    // Set the Enable PIN right after power up.
    LL_GPIO_ResetOutputPin(GPIOB, LL_GPIO_PIN_ENABLE);
    LL_mDelay(5);
    LL_GPIO_SetOutputPin(GPIOB, LL_GPIO_PIN_ENABLE);
    LL_mDelay(3);
    
    //Set the OSC_Enable pin for internal TDC clock.  
    LL_GPIO_SetOutputPin(GPIOB, LL_GPIO_PIN_TDC_OSC_ENABLE);

2) SPI CONFIG:

SPI1InitStruct.BaudRate = LL_SPI_BAUDRATEPRESCALER_DIV2;
SPI1InitStruct.ClockPhase = LL_SPI_PHASE_2EDGE;
SPI1InitStruct.ClockPolarity = LL_SPI_POLARITY_LOW;
SPI1InitStruct.CRCCalculation = LL_SPI_CRCCALCULATION_DISABLE;
SPI1InitStruct.DataWidth = LL_SPI_DATAWIDTH_8BIT;
SPI1InitStruct.TransferDirection = LL_SPI_FULL_DUPLEX;
SPI1InitStruct.BitOrder = LL_SPI_MSB_FIRST;
SPI1InitStruct.Mode = LL_SPI_MODE_MASTER;
SPI1InitStruct.NSS = LL_SPI_NSS_SOFT;

SPI1InitStruct.BaudRate = LL_SPI_BAUDRATEPRESCALER_DIV2;
SPI1InitStruct.ClockPhase = LL_SPI_PHASE_2EDGE;
SPI1InitStruct.ClockPolarity = LL_SPI_POLARITY_LOW;
SPI1InitStruct.CRCCalculation = LL_SPI_CRCCALCULATION_DISABLE;
SPI1InitStruct.DataWidth = LL_SPI_DATAWIDTH_8BIT;
SPI1InitStruct.TransferDirection = LL_SPI_FULL_DUPLEX;
SPI1InitStruct.BitOrder = LL_SPI_MSB_FIRST;
SPI1InitStruct.Mode = LL_SPI_MODE_MASTER;
SPI1InitStruct.NSS = LL_SPI_NSS_SOFT;

LL_SPI_Init(SPI1, &SPI1InitStruct);
LL_SPI_SetRxFIFOThreshold(SPI1, LL_SPI_RX_FIFO_TH_QUARTER);
LL_SPI_Enable(SPI1);

3) Function: Write Register:

 if (!LL_SPI_IsEnabled(SPI1))
    {
        LL_SPI_Enable(SPI1);
    }

    uint8_t  raddr;

    raddr = TDC_WRT_MASK | address; // set addr bits 7 to 0 & 6 to 1 for write.

    LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_4); // slave select (low)

    LL_SPI_TransmitData8(SPI1, raddr); // send reg address.
    LL_SPI_TransmitData8(SPI1, value); // send Reg value data.

    while (!LL_SPI_IsActiveFlag_TXE(SPI1))
        ;

    while (LL_SPI_IsActiveFlag_BSY(SPI1))
        ;

    LL_GPIO_SetOutputPin(GPIOA, LL_GPIO_PIN_4); // slave deselect (high)
    LL_SPI_Disable(SPI1);

4) Function: Read Register:

    if (!LL_SPI_IsEnabled(SPI1))
    {
        LL_SPI_Enable(SPI1);
    }

    uint8_t data = 0x00;

    uint8_t raddr;

    raddr = address; // set addr bits 7 & 6 to 0 for read

    LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_4); // slave select (low)

    LL_SPI_TransmitData8(SPI1, raddr);

    while (!LL_SPI_IsActiveFlag_TXE(SPI1))
        ; // wait while not empty

    while (LL_SPI_IsActiveFlag_BSY(SPI1))
        ; // wait while busy,

    *(volatile uint8_t*)&SPI1->DR = 0; // dummy write

    while (!LL_SPI_IsActiveFlag_RXNE(SPI1))
        ; 

    data = LL_SPI_ReceiveData8(SPI1);
    
    LL_GPIO_SetOutputPin(GPIOA, LL_GPIO_PIN_4); // slave select (low)
    
    LL_SPI_Disable(SPI1);

    return data;

When i Write and read after write i am getting 0x00.

Image 1: Master Out Slave In (MOSI:Green, SCLK: Pink, Chip Select: Blue)

Image 2: Master In Slave Out (MISO:Green, SCLK: Pink, Chip Select: Blue)

  • Hello,

    Welcome to the E2E forum.

    Can you please share a capture for the CSBx, SCLK, DIN, and DOUTx while you execute the code?

    This will help me more easily compare your results to the expected result. 

    Please let me know if you have any questions,

    Best regards,

    Jacob

  • Added screenshots to my original post.

  • Hello,

    I ran your commands on my EVM and captured the SPI communication data:

    Green: DIN, Pink: SCLK, Blue: CS, Yellow: Dout.

    Writing to address 01h, value: 041h 

    Reading address 01h, return value 041h

    It looks like our waveforms are identical in data, however I am concerned the noise observed on some of your traces may be influencing the SPI communication. 

    Have you attempted to read any other register values yet? 

    If not, please try to read register address 03h or 04h. These registers will have data within them from factory. I would like to see if this issue is exists on both the read and write cycles. 

    Please let me know if you have any questions,

    Regards,

    Jacob

  • Hello Jacob,

    Thanks so much for your reply. So since you ran the code, it looks like the functions seem to work as expected. I need to investigate if I can get rid of the noise.

    I tried reading registers 03 and 04 and i still see 0.

    This is what i run in main function.

    while (1)
    {
    var1 = read_register(0x03);
    LL_mDelay(1);
    var2 = read_register(0x04);
    LL_mDelay(1);

    }

    Can you tell me how exactly you have connected the ST and TDC?  I suspect there's a problem with my hardware.

    I have connected a GPIO OUT pin of ST to Vcc of TDC Eval board. This is reset and then Set, right at program start. And after a few milliseconds, I set the Enable PIN as described in the datasheet. May be the TDC has been already reset a lot of times? Could this be the reason?

  • Hi Abel,

    Thank you for testing the read commands for me. 

    Sorry for the confusion in my last post, I had run the same read/write commands as you, but used an MSP430 to communicate. The TDC7201 EVM has an accompanying GUI if you attach an MSP430G2553 launchpad to the EVM. 

    In my case, I am using DOUT1, DIN, CSB1 and SCLK for the communication.

    We have an EVM schematic in the TDC7201 EVM User's Guide, this may help us debug if any hardware issues exist for your setup.

    The VCC pin can be connected to a 3.3V rail, as the enable pin is the only pin you need to sequence. Startup requires the enable pin be transitioned low to high sometime after the device has supply.  

    Additionally, do you have both jumpers populated on the EVM board?

    I am always happy to take scope shots of my setup if you require information on expected input/output.

    Please let me know if you have any questions,

    Best Regards,

    Jacob

  • Yes both jumpers are populated on the EVM board.

    Somehow, the signal level from DOUT1 line from TDC going into ST Eval board does not seem very reasonable. This line is configured as an Input.

    Clock from Master (Red) MOSI (Yellow); and CS (Blue) line make sense. 

  • Hi Abel,

    What is the digital logic high voltage from the microcontroller? Just want to make sure the micro is using 3.3V logic. 

    It looks like the transients on some of the lines may be exceeding the ABS max datasheet specifications (VCC+.3V). Can you try to reduce these transients/clean up the signals. I suspect the noise we see on the DOUT1 line is being caused by excessive voltage on SCLK and maybe MOSI.

    Feel free to measure the min and max voltage on these lines, it is possible my eyeball voltage estimations are incorrect. 

  • Hello Jacob,

    I tried reducing the clock Rate to 62.5KHz. This is the most stable (less noisy) voltage levels i could obtain. I was not able to get rid of the transients entirely. Clock , MOSI and CS lines are at 3.6V . Is this too high for the TDC board?

  • Hi Abel, 

    3.6V may be tolerable depending on the supply voltage to the TDC board. 

    If the supply is 3.3V, then 3.6V input is at the ABS max condition limit, and outside the recommended operating range:

    Exceeding ABS max conditions can cause permanent damage to the device. Exceeding recommended operating conditions for extended periods of time can also influence device reliability. 

     The voltage levels look more stable in this scope shot compared to the previous setup. 

    What is the supply voltage you are using for the TDC?

    BR,

    Jacob

  • Hi Jacob,

    Supply Voltage on Vcc pin is 3.3V. This is always on, since it is connected from the ST Board. Everytime I flash a a new software, only the initial sequence of Enable PIN is reconfigured.

    Best Regards

    Abel

  • Hi Abel,

    I think I may have found the culprit to the issue you have been encountering.

    Data is latched on the rising edge of SCLK for the TDC7201, and in your waveforms, the data lines are changing states while SCLK is rising. 

    See below for the access example:

    Please change the phase offset of the SCLK line, and let me know if this helps get the device working. 

    Best Regards,

    Jacob

  • I changed the SCLK polarity, there is no change unfortunately. I'm worried that the board itself might be damaged.

  • Hi Abel,

    I'm sorry the change in SCLK polarity did not fix the issue. 

    It looks like the communication should otherwise be working to me.

    There are a few possible avenues to pursue here: 

    1. You can purchase the MSP430F5529 to evaluate the EVM with the TDC7201 GUI. Note, this would only be of assistance in the case the TC7201 device was functional.

    2. You can purchase a new TDC7201 device to replace the current EVM device. The device uses a BGA package, so this can be somewhat difficult depending on the soldering tools you have access to. 

    In my opinion, it seems possible that the device has become damaged. It may be worthwhile to swap out the device on the EVM to start testing with a fresh device. Alternatively, you could procure the MSP430, and use the GUI to verify if the device has been damaged. 

    I am happy to take any scope-shots of my device if it helps you in any way, but it looks like our communication protocol is now identical in operation. 

    Please let me know if you have any questions,

    Thank you,

    Jacob

  • Hello Jacob,

    I am getting FFs using the TI MSP board now.

    Even after resetting the EVM board via EVM GUI, I'm reading FFs using EVM GUI. Does this mean the device is damaged?

    Thanks

    Abel

  • Hi Abel, 

    Thanks for trying the EVM with the MSP. 

    Was the FF result coming from all register read commands? If this is the case, I would expect the board to be damaged.  

    This application note details BGA assembly recommendations: snoa021c

    Additionally, it looks like we have stock of the TDC7201 on TI.com

    Please let me know if you have any questions,

    Best Regards,

    Jacob

  • Hello Jacob,

    Yes I'm reading FFs from all registers. Thank you for the BGA Assembly recommendations.

    Best Regards

    Abel.

  • Hi Abel,

    Sorry the issue ended up being damage within the device, I was hoping the issue was related to communication protocol or register settings. 

    Please let me know if you have any questions while replacing the device. 

    Regards,

    Jacob