TMS320F280037: CMPPS+ECAP

Part Number: TMS320F280037
Other Parts Discussed in Thread: SYSCONFIG

I am working with the TMS320F280037C microcontroller and trying to implement a PLL using the CMPSS and eCAP modules. However, I am not able to get the expected high and low output on the GPIO pin(XBAR ). 

static void init_fnCMPSS1(void)
{
    CMPSS_disableModule(CMPSS1_BASE);

    ASysCtl_selectCMPHPMux(ASYSCTL_CMPHPMUX_SELECT_1, 3U);
    ASysCtl_selectCMPLPMux(ASYSCTL_CMPLPMUX_SELECT_1, 3U);

    //
    // Configure internal DAC as reference (1.65V)
    //
    CMPSS_configDAC(CMPSS1_BASE,
                    CMPSS_DACVAL_SYSCLK |
                    CMPSS_DACREF_VDDA |
                    CMPSS_DACSRC_SHDW);

    CMPSS_setDACValueHigh(CMPSS1_BASE, 2048U);
    CMPSS_setDACValueLow(CMPSS1_BASE, 2048U);

    CMPSS_configHighComparator(CMPSS1_BASE, CMPSS_INSRC_PIN);

    CMPSS_configOutputsHigh(CMPSS1_BASE,
                            CMPSS_TRIPOUT_ASYNC_COMP | CMPSS_TRIP_ASYNC_COMP);

    CMPSS_setHysteresis(CMPSS1_BASE, 0U);

    CMPSS_enableModule(CMPSS1_BASE);

    DEVICE_DELAY_US(500);
}


static void init_fnDAC(void)
 {
    /*
     * Set VDAC as the DAC reference voltage.
     * Edit here to use ADC VREF as the reference voltage.
     */
    DAC_setReferenceVoltage(DACA_BASE, DAC_REF_VDAC);

    DAC_setLoadMode(DACA_BASE, DAC_LOAD_SYSCLK);

    /*
     * Enable the DAC output
     */
    DAC_enableOutput(DACA_BASE);

    /*
     * Set the DAC shadow output to 0
     */
    DAC_setShadowValue(DACA_BASE, 0U);

    /*
     * Delay for buffered DAC to power up
     */
    DEVICE_DELAY_US(500);
    /*
     * Set VDAC as the DAC reference voltage.
     * Edit here to use ADC VREF as the reference voltage.
     */
    DAC_setReferenceVoltage(DACB_BASE, DAC_REF_VDAC);

    DAC_setLoadMode(DACB_BASE, DAC_LOAD_SYSCLK);

    /*
     * Enable the DAC output
     */
    DAC_enableOutput(DACB_BASE);

    /*
     * Set the DAC shadow output to 0
     */
    DAC_setShadowValue(DACB_BASE,0U);
    /*
     * Delay for buffered DAC to power up
     */
    DEVICE_DELAY_US(500);

 }

static void init_fnInitEcap1(void)
{
    //
    // Disable ,clear all capture flags and interrupts
    //
    ECAP_disableInterrupt(ECAP1_BASE, (ECAP_ISR_SOURCE_CAPTURE_EVENT_1 |
    ECAP_ISR_SOURCE_CAPTURE_EVENT_2 |
    ECAP_ISR_SOURCE_CAPTURE_EVENT_3 |
    ECAP_ISR_SOURCE_CAPTURE_EVENT_4 |
    ECAP_ISR_SOURCE_COUNTER_OVERFLOW |
    ECAP_ISR_SOURCE_COUNTER_PERIOD |
    ECAP_ISR_SOURCE_COUNTER_COMPARE));
    ECAP_clearInterrupt(ECAP1_BASE, (ECAP_ISR_SOURCE_CAPTURE_EVENT_1 |
    ECAP_ISR_SOURCE_CAPTURE_EVENT_2 |
    ECAP_ISR_SOURCE_CAPTURE_EVENT_3 |
    ECAP_ISR_SOURCE_CAPTURE_EVENT_4 |
    ECAP_ISR_SOURCE_COUNTER_OVERFLOW |
    ECAP_ISR_SOURCE_COUNTER_PERIOD |
    ECAP_ISR_SOURCE_COUNTER_COMPARE));
    //
    // Disables time stamp capture.
    //
    ECAP_disableTimeStampCapture(ECAP1_BASE);
    //
    // Stops Time stamp counter.
    //
    ECAP_stopCounter(ECAP1_BASE);
    //
    // Sets eCAP in Capture mode.
    //
    ECAP_enableCaptureMode(ECAP1_BASE);
    //
    // Sets the capture mode.
    //
    ECAP_setCaptureMode(ECAP1_BASE, ECAP_CONTINUOUS_CAPTURE_MODE, ECAP_EVENT_1);
    //
    // Sets the Capture event prescaler.
    //
    ECAP_setEventPrescaler(ECAP1_BASE, 0U);
    //
    // Sets the Capture event polarity.
    //
    ECAP_setEventPolarity(ECAP1_BASE, ECAP_EVENT_1, ECAP_EVNT_FALLING_EDGE);
    ECAP_setEventPolarity(ECAP1_BASE, ECAP_EVENT_2, ECAP_EVNT_FALLING_EDGE);
    ECAP_setEventPolarity(ECAP1_BASE, ECAP_EVENT_3, ECAP_EVNT_FALLING_EDGE);
    ECAP_setEventPolarity(ECAP1_BASE, ECAP_EVENT_4, ECAP_EVNT_FALLING_EDGE);
    //
    // Configure counter reset on events
    //
    ECAP_enableCounterResetOnEvent(ECAP1_BASE, ECAP_EVENT_1);
    ECAP_disableCounterResetOnEvent(ECAP1_BASE, ECAP_EVENT_2);
    ECAP_disableCounterResetOnEvent(ECAP1_BASE, ECAP_EVENT_3);
    ECAP_disableCounterResetOnEvent(ECAP1_BASE, ECAP_EVENT_4);

    // Connect CMPSS1 high output to INPUTXBAR1
     XBAR_setInputPin(INPUTXBAR_BASE, XBAR_INPUT1, XBAR_INPUT_FLG_CMPSS1_CTRIPH);

    //
    // Select eCAP input.
    //
    ECAP_selectECAPInput(ECAP1_BASE, ECAP_INPUT_INPUTXBAR1);
    //
    // Sets a phase shift value count.
    //
    ECAP_setPhaseShiftCount(ECAP1_BASE, 0U);
    //
    // Enable counter loading with phase shift value.
    //
    ECAP_enableLoadCounter(ECAP1_BASE);
    //
    // Configures Sync out signal mode.
    //
    ECAP_setSyncOutMode(ECAP1_BASE, ECAP_SYNC_OUT_DISABLED);
    //
    // Configures emulation mode.
    //
    ECAP_setEmulationMode(ECAP1_BASE, ECAP_EMULATION_FREE_RUN);
    //
    // Set up the source for sync-in pulse..
    //
    ECAP_setSyncInPulseSource(ECAP1_BASE, ECAP_SYNC_IN_PULSE_SRC_DISABLE);
    //
    // Starts Time stamp counter for myECAP0.
    //
    ECAP_startCounter(ECAP1_BASE);
    //
    // Enables time stamp capture for myECAP0.
    //
    ECAP_enableTimeStampCapture(ECAP1_BASE);
    //
    // Re-arms the eCAP module for myECAP0.
    //
    ECAP_reArm(ECAP1_BASE);
    //
    // Enables interrupt source for myECAP0.
    //
    ECAP_enableInterrupt(ECAP1_BASE, (ECAP_ISR_SOURCE_CAPTURE_EVENT_1));
}

 

static void gpio_fnConfigOutputPins(void)
{
    XBAR_setOutputMuxConfig(XBAR_BASE, XBAR_OUTPUT7, XBAR_OUT_MUX00_CMPSS1_CTRIPOUTH);
    XBAR_enableOutputMux(XBAR_BASE, XBAR_OUTPUT7, XBAR_MUX00);
    // Connect XBAR Output7 to GPIO16
    GPIO_setPinConfig(GPIO_16_OUTPUTXBAR7);
    GPIO_setDirectionMode(16, GPIO_DIR_MODE_OUT);

}

  • Hi Anusree,

    Can you provide a more detailed description of the usage for each of these functions?

    Can you provide the details of your test setup? Are you using a launchpad? What are you using to probe the GPIO16 pin?

    Are you using the SysConfig tool to assist with device configurations? If so, please share the .syscfg file for reference.

    Have you verified that each of the compontents is working independently? Drive the DAC signal to a pin and verify it is generating the proper signal needed to trigger the CMPSS. Then validate that the CMPSS is working and triggering as expected, then validate that the ECAP is both capturing the CMPSS trigger and generating a valid pulse, then we can futher debug why the signal isn't showing on the given pin.

    Thanks for the additional details.

    Best Regards,

    Zackary Fleenor

  • CMPSS is working properly; we are able to generate logic 0 and 1, but the output is not visible on the GPIO pin.

  • Hey Anusree,

    Can you also respond to the other questions?

    What are you using to measure the voltage level on the GPIO pin?

    Are you using SysConfig?

    Best Regards,

    Zackary Fleenor