Part Number:TDC7201-ZAX-EVM
Tool/software: Code Composer Studio
I am using a TDC720x-ZAX-EVM to determine if this is the correct TOF microchip and I am running into some issues with the evaluation module. I was able to get excellent readings on the GUI with a function generator, and then began to experiment using the code composer code that was supplied by TI in the demo_apps folder, and was unsuccessful in getting anything to work and the only thing that happened was LED102 and LED101 would light up and stay lit. I decided to plug the TDC720x-ZAX-EVM back into the function wave generator and test TDC1 again, and even though my setup had not changed, TDC1 was no longer reading any measurements. I tried the same setup with TDC2 and was able to read measurements with no problem. I altered the code to use TDC2 instead of TDC1 and then attempted to do measurements through the GUI and noted that TDC2 was no longer taking any measurements. Has anyone ran into this problem before and found a fix?
Here is the TI code I was using.
//******************************************************************************
// Demo Application01 for MSP430/TDC720x Interface Code Library v1.0
// Byte Read/ Byte Write TDC720x Registers
//
// MSP430F5529
// -----------------
// /|\| XIN|-
// | | |
// --|RST XOUT|-
// | |
// | P3.0/UCB0SIMO|--> SDI
// | P3.1/UCB0SOMI|<-- SDO
// | P3.2/UCB0CLK|--> CLK
// | P2.6|--> CSB
// | P2.4|
// | |
// | P1.2|
//
// Vishy Natarajan
// Texas Instruments Inc.
// March 2013
// Built with IAR Embedded Workbench Version: 5.5x
//******************************************************************************
/* Copyright 2011-2012 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user who
downloaded the software, his/her employer (which must be your employer) and
Texas Instruments Incorporated (the "License"). You may not use this Software
unless you agree to abide by the terms of the License. The License limits your
use, and you acknowledge, that the Software may not be modified, copied or
distributed unless embedded on a Texas Instruments microcontroller which is
integrated into your product. Other than for the foregoing purpose, you may
not use, reproduce, copy, prepare derivative works of, modify, distribute,
perform, display or sell this Software and/or its documentation for any
purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL TEXAS
INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER LEGAL
EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES INCLUDING BUT NOT
LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR CONSEQUENTIAL
DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF SUBSTITUTE GOODS,
TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT
LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
*******************************************************************************/
#include <stdint.h>
#include "TI_TDC720x.h"
#include "TI_MSP430.h"
#include "TI_MSP430_hardware_board.h"
#include "TI_MSP430_spi.h"
#include "HAL_PMM.h"
void Init_Clock (void);
void InitMCU(void);
// Test TDC720x Register Read/Write & Conversion
uint32_t clk_count;
uint8_t read_val[3], all_data[TDC720x_ALL_DATA_SIZE], byte_data;
uint32_t tout = 0;
uint8_t TDC720x_Parallel_Read = 1;
//******************************************************************************
void main(void)
{
WDTCTL = WDTPW+WDTHOLD; // Stop WDT
TI_TDC720x_GLED_PxOUT |= TI_TDC720x_GLED_PIN; // Set LED ON
TI_TDC720x_GLED_PxDIR |= TI_TDC720x_GLED_PIN; // Set pin direction is output
__delay_cycles(250000);
TI_TDC720x_GLED_PxOUT ^= TI_TDC720x_GLED_PIN;
TI_TDC720x_RLED_PxOUT &= ~TI_TDC720x_RLED_PIN; // Set RLED OFF
TI_TDC720x_RLED_PxDIR |= TI_TDC720x_RLED_PIN; // Set pin direction
TI_TDC720x_OSCENABLE_PxOUT |= TI_TDC720x_OSCENABLE_PIN; // Set pin high: enable afe osc
TI_TDC720x_OSCENABLE_PxDIR |= TI_TDC720x_OSCENABLE_PIN; // Set pin direction is output
TI_TDC720x_ENABLE1_PxOUT |= TI_TDC720x_ENABLE1_PIN; // Enable device
TI_TDC720x_ENABLE1_PxDIR |= TI_TDC720x_ENABLE1_PIN; // Set pin direction output
#if 0
TI_TDC720x_FLAG_PxOUT |= TI_TDC720x_FLAG_PIN; // Flag Input Pull up enable
TI_TDC720x_FLAG_PxREN |= TI_TDC720x_FLAG_PIN; // Flag Input Resistor enable
TI_TDC720x_FLAG_PxDIR &= ~TI_TDC720x_FLAG_PIN; // Set pin direction input
#endif
// configure Port Pin to handle Interrupt Bar Output (INTB) from TDC720x
TI_TDC720x_INTB_PxDIR &= ~TI_TDC720x_INTB1_PIN; // Set up port pin for INTB
TI_TDC720x_INTB_PxOUT |= TI_TDC720x_INTB1_PIN; // INTB Input Pull up enable
TI_TDC720x_INTB_PxREN |= TI_TDC720x_INTB1_PIN; // INTB Input Resistor enable
TI_TDC720x_INTB_PxIES |= TI_TDC720x_INTB1_PIN; // Interrupt Edge Select
TI_TDC720x_INTB_PxIFG &= ~TI_TDC720x_INTB1_PIN; // Clear Interrupt Flag
// TI_TDC720x_INTB_PxIE |= TI_TDC720x_INTB1_PIN; // Enable Port interrupt
// oscillator fail if LED keeps flashing after InitMCU
InitMCU();
TI_TDC720x_SPIByteWriteReg(TI_TDC720x_CONFIG1_REG, 0x01, TDC720x_TDC2);
TI_TDC720x_SPISetup(); // Initilaize MSP430 SPI Block
// Test TDC720x Register Read/Write & Conversion
read_val[0] = TI_TDC720x_SPIByteReadReg(0x00, TDC720x_TDC2);
read_val[1] = TI_TDC720x_SPIByteReadReg(0x01, TDC720x_TDC2);
read_val[2] = TI_TDC720x_SPIByteReadReg(0x03, TDC720x_TDC2);
TI_TDC720x_SPIByteWriteReg(0x01, 0x40, TDC720x_TDC2);
read_val[0] = TI_TDC720x_SPIByteReadReg(0x00, TDC720x_TDC2);
read_val[1] = TI_TDC720x_SPIByteReadReg(0x01, TDC720x_TDC2);
read_val[2] = TI_TDC720x_SPIByteReadReg(0x03, TDC720x_TDC2);
#if 0
// read config1 register
byte_data = TI_TDC720x_SPIByteReadReg(TI_TDC720x_CONFIG1_REG, TDC720x_TDC2);
// set mode 2 & start measurement bit
byte_data |= 0x03;
TI_TDC720x_SPIByteWriteReg(TI_TDC720x_CONFIG1_REG, byte_data, TDC720x_TDC2);
//wait for INTB pin to go low
tout = 0;
while(TI_TDC720x_INTB_PxIN & TI_TDC720x_INTB2_PIN)
{
tout++;
if (tout >= TIMEOUT_VALUE)
break;
}
TI_TDC720x_SPIAllReadReg(all_data, TDC720x_TDC2);
clk_count = TI_TDC720x_SPILongReadReg(0x11, TDC720x_TDC2);
#endif
// test if byte write/read values match
if (read_val[1] == 0x40)
{
while (1) // no error: blink LED continuously
{
__delay_cycles(250000);
__delay_cycles(250000);
TI_TDC720x_GLED_PxOUT ^= TI_TDC720x_GLED_PIN;
}
} else
{
TI_TDC720x_GLED_PxOUT &= ~TI_TDC720x_GLED_PIN; // error: Set LED OFF
}
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, enable interrupts
__no_operation(); // For debugger
}
//******************************************************************************
//******************************************************************************
/**
* @brief Function Name: Init_Clock .
* @brief Description : Initializes MSP430 clock module.
* @param parameters : none
* @return Value : none
*/
//******************************************************************************
void Init_Clock(void)
{
// UCSCTL3 = SELREF_2; // Set DCO FLL reference = REFO
// UCSCTL4 |= SELA_2; // Set ACLK = REFO
// Enable XT2 XIN/XOUT Pins
P5SEL |= 0x0C; // Select XIN, XOUT on P5.3 and P5.2
UCSCTL6 &= ~XT2OFF; // Enable XT2
UCSCTL6 |= XT2DRIVE_3;
P5SEL |= BIT4+BIT5; // Select XT1
UCSCTL6 &= ~(XT1OFF); // XT1 On
UCSCTL6 |= XCAP_3; // Internal load cap
UCSCTL3 = 0; // FLL Reference Clock = XT1
// Loop until XT1,XT2 & DCO stabilizes - In this case loop until XT1 and DCo settle
do
{
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG);
// Clear XT2,XT1,DCO fault flags
SFRIFG1 &= ~OFIFG; // Clear fault flags
TI_TDC720x_RLED_PxOUT ^= TI_TDC720x_RLED_PIN; // Toggle LED
__delay_cycles(250000);
}while (SFRIFG1&OFIFG); // Test oscillator fault flag
UCSCTL6 &= ~(XT1DRIVE_3); // Xtal is now stable, reduce drive strength
UCSCTL4 |= SELA_0; // ACLK = LFTX1 (by default)
__bis_SR_register(SCG0); // Disable the FLL control loop
UCSCTL0 = 0x0000; // Set lowest possible DCOx, MODx
UCSCTL1 = DCORSEL_7; // Select DCO range 50MHz operation
UCSCTL2 = FLLD_0 + 747; // Set DCO Multiplier(762/498) for 25MHz/16MHz
// (N + 1) * FLLRef = Fdco
// (762 + 1) * 32768 = 25MHz
// Set FLL Div = fDCOCLK/2
__bic_SR_register(SCG0); // Enable the FLL control loop
// Worst-case settling time for the DCO when the DCO range bits have been
// changed is n x 32 x 32 x f_MCLK / f_FLL_reference. See UCS chapter in 5xx
// UG for optimization.
// 32 x 32 x 25 MHz / 32,768 Hz ~ 780k MCLK cycles for DCO to settle
__delay_cycles(782000);
// Loop until XT1,XT2 & DCO stabilizes - In this case only DCO has to stabilize
do
{
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG);
// Clear XT2,XT1,DCO fault flags
SFRIFG1 &= ~OFIFG; // Clear fault flags
TI_TDC720x_RLED_PxOUT ^= TI_TDC720x_RLED_PIN; // Toggle LED
__delay_cycles(250000);
}while (SFRIFG1&OFIFG); // Test oscillator fault flag
UCSCTL4 = SELA__XT1CLK + SELS__DCOCLKDIV + SELM__DCOCLKDIV; // SMCLK=MCLK=
// Loop until XT1,XT2 & DCO stabilizes - In this case only DCO has to stabilize
do
{
UCSCTL7 &= ~(XT2OFFG + XT1LFOFFG + DCOFFG);
// Clear XT2,XT1,DCO fault flags
SFRIFG1 &= ~OFIFG; // Clear fault flags
TI_TDC720x_RLED_PxOUT ^= TI_TDC720x_RLED_PIN; // Toggle LED
__delay_cycles(250000);
}while (SFRIFG1&OFIFG); // Test oscillator fault flag
TI_TDC720x_RLED_PxOUT &= ~TI_TDC720x_RLED_PIN; // turn off red
}
//******************************************************************************
/**
* @brief Local functions.
*/
/**
* @brief Function Name: InitMCU.
* @brief Description : Initializes the MSP430 peripherals and modules.
* @param parameters : none
* @return Value : none
*/
//******************************************************************************
void InitMCU(void)
{
__disable_interrupt(); // Disable global interrupts
SetVCore(3);
Init_Clock(); //Init clocks
__enable_interrupt(); // enable global interrupts
}
//******************************************************************************
the only thing altered is TDC2 is selected and used rather than TDC1.