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.

CC1310: CC13xx TDC never finishes

Part Number: CC1310

i've encountered the same issue as raised in this earlier question, but could never seem to find the resolution....

is there an example that use the TDC (from the M3, not the sensor controller) to measure the time between (say) a rising and falling edge of some input pin????

thanks....

  • Hi Bob,

    There are unfortunately no such example, the closest you get to this functionality in terms of drivers is the GPTimer driver that has "edge-time" mode. There is some TDC usage in the Power driver as well during the calibration routine, it would be possible to extract the "how to-do" from there with some careful dissection.
  • it's strange that the boilerplate i received noted that this issue was marked "resolved"....  unless there is more to this thread, here's the last contribution:

    I've had a bit of luck getting things going today, turns out I wasn't setting the following registers: AUX_WUC_AUXIOLATCH, AUX_AIODIO_GPIODIE and AUX_AIODIO_IOMODE. After setting them, edges are detected and a result is produced; however, the result is garbage. The result (from AUX_TDC_RESULT) is always either 2 or 3, and I'm sending in a 1 Hz signal (same thing happens with 150 Hz, 1k Hz, etc.).

    in any event, i suspect the GPT is my best (and only) path here....

  • Hi Bob,

    How do your TDC test code look today, could you share it? Also, did you review the PowerCC26XX_calibrateRCOSC.c file to see how TDC is used there?
  • for the record, i *have* been able to successfully use the TDC to calibrate the LFOSC for quite some time now....  i basically followed the code in PowerCC26xx_calibrateRCOSC.c

    my issue with the TDC is when i recently tried to measure the time between two pin inputs....  couldn't get that to work; and found this thread in which someone else apparently had issues....

    i've been pursuing the GPT approach (documented in another thread) as my alternative....

    the TDC has some advantages over the GPT in my particular use-case....

    it conceptually seems simpler than arranging for two GPT modules to work in lock-step to capture the time when two distinct edges change....

    and since i'm measuring signals originating in the radio core that are *already* mapped to GPIOs, the GPT approach requires me to detect two additional pins which i then have to externally connect to my true inputs....

    the TDC can simply name the GPIOs are the start/stop condition....

    if at all possible, i'd prefer to go this route if someone could verify the functionality....

  • Hi Bob,

    I have played around with the TDC on M3 level and gotten it to work, check example code below for how to measure IO30:

        /* Enable the AUX clocks and change the ref. clock */
        AUXWUCClockFreqReq(AUX_WUC_CLOCK_HIFREQ);
        AUXWUCClockEnable(AUX_WUC_TDCIF_CLOCK | AUX_WUC_AIODIO0_CLOCK | AUX_WUC_TDC_CLOCK);
    
        /* Allocate the pins to use */
        buttonPinHandle = PIN_open(&buttonPinState, buttonPinTable);
        if(!buttonPinHandle) {
            /* Error initializing button pins */
            while(1);
        }
    
        /* Mux IO30 to AUXIO0 (hard connection)*/
        PINCC26XX_setMux(buttonPinHandle, IOID_30, IOC_PORT_AUX_IO);
    
        HWREG(AUX_WUC_BASE + AUX_WUC_O_AUXIOLATCH) = 0x1;
    
        /* Configure AUXIO0 as input */
        HWREG(AUX_AIODIO0_BASE + AUX_AIODIO_O_IOMODE) = AUX_AIODIO_IOMODE_IO0_IN;
        HWREG(AUX_AIODIO0_BASE + AUX_AIODIO_O_GPIODIE) = 0x1;
        HWREG(AUX_WUC_BASE + AUX_WUC_O_AUXIOLATCH) = 0x1;
    
        /* set TDC_SRC clock to be XOSC_HF = 24 MHz */
        DDI16BitfieldWrite(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_CTL0,
            DDI_0_OSC_CTL0_ACLK_TDC_SRC_SEL_M,
            DDI_0_OSC_CTL0_ACLK_TDC_SRC_SEL_S, 2);
    
        /* read back to ensure no race condition between OSC_DIG and AUX_WUC */
        DDI16BitfieldRead(AUX_DDI0_OSC_BASE, DDI_0_OSC_O_CTL0,
              DDI_0_OSC_CTL0_ACLK_TDC_SRC_SEL_M, DDI_0_OSC_CTL0_ACLK_TDC_SRC_SEL_S);
    
        /* Force TDC into Idle before configuration */
        AUXTDCIdleForce(AUX_TDC_BASE);
        while (!AUXTDCIdle(AUX_TDC_BASE)){};
    
        /* Configure TDC to catch a event in AUXIO0:
         * Falling -> Rising edge */
        AUXTDCConfigSet(AUX_TDC_BASE, (AUXTDC_START_AUXIO0 | AUXTDC_STARTPOL_FALL), (AUXTDC_STOP_AUXIO0 | AUXTDC_STOPPOL_RIS));
    
        /* Count one event only */
        AUXTDCCounterSet(AUX_TDC_BASE, 0);
        AUXTDCCounterEnable(AUX_TDC_BASE);
    
        while (1) {
            /* Run TDC */
            AUXTDCEnable(AUX_TDC_BASE, AUX_TDC_RUNSYNC);
    
            uint32_t status = AUX_TDC_BUSY;
            while (status == AUX_TDC_BUSY)
            {
                status = AUXTDCMeasurementDone(AUX_TDC_BASE);
            };
    
            /* The TDC counts both rising and falling clock edges, divide by two
             * to get number of clock cycles.
             */
            uint32_t value = AUXTDCMeasurementGet(AUX_TDC_BASE) >> 1;
        }