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.

CCS/TMS320F280049: SDFM: PWM sync problem

Part Number: TMS320F280049
Other Parts Discussed in Thread: AMC1035,

Tool/software: Code Composer Studio

I am using SDFM module in TMS320F280049 with AMC1035. 

I would like to have synchronized measurement with PWM1 module which generates signal at 50kHz .

My problem is when I enable synchronization from PWM1 and a particular interrupt from SDFM occurs I get a wrong results. The interrupt is invoked in periodic way of 20us which is as expected. When I disable PWM synchronization I can get a correct result in ISR. The PWM1 is configured to generate SOC_A when time-base counter is equal to period. So it should be 

My configuration is following:
SDFM1 Filter Settings : Only FILTER4 is enabled, SINC3, OSR 128, SD_CLK = 10MHz, @ data rate frequency = 78kHz, latency 38.4us

Initialization code: It is based on example code from C2000 ware. 

void init_SDFM(void)
{
    //pin config
    GPIO_setDirectionMode(58, GPIO_DIR_MODE_IN);
    GPIO_setMasterCore(58, GPIO_CORE_CPU1);
    GPIO_setPadConfig(58, GPIO_PIN_TYPE_STD);
    GPIO_setQualificationMode(58, GPIO_QUAL_ASYNC);
    GPIO_setPinConfig(GPIO_58_SD_D4);

    GPIO_setDirectionMode(59, GPIO_DIR_MODE_IN);
    GPIO_setMasterCore(59, GPIO_CORE_CPU1);
    GPIO_setPadConfig(59, GPIO_PIN_TYPE_STD);
    GPIO_setQualificationMode(59, GPIO_QUAL_ASYNC);
    GPIO_setPinConfig(GPIO_59_SD_C4);

    //
    // Configure Input Control Unit: Modulator Clock rate = Modulator data rate
    //
    SDFM_setupModulatorClock(SDFM1_BASE, SDFM_FILTER_4, SDFM_MODULATOR_CLK_OFF);
    SDFM_configDataFilter(SDFM1_BASE, (SDFM_FILTER_4 | SDFM_FILTER_SINC_3 | SDFM_SET_OSR(128)), (SDFM_DATA_FORMAT_16_BIT | SDFM_FILTER_ENABLE | SDFM_SHIFT_VALUE(0x0006)));
    //
    // Enable Master filter bit: Unless this bit is set none of the filter
    // modules can be enabled. All the filter modules are synchronized when
    // master filter bit is enabled after individual filter modules are enabled.
    //
    SDFM_enableMasterFilter(SDFM1_BASE);

    //
    // Set the output data format
    //
    SDFM_setOutputDataFormat(SDFM1_BASE, SDFM_FILTER_4, SDFM_DATA_FORMAT_16_BIT);

    //
    // Disable PWM sync 
    //
    //SDFM_disableExternalReset(SDFM1_BASE, SDFM_FILTER_4);

    //
    // PWM signals can synchronize SDFM1 filters. Enabling PWM sync for SDFM
    // filters.
    //
    SDFM_enableExternalReset(SDFM1_BASE, SDFM_FILTER_4);
    SDFM_setPWMSyncSource(SDFM1_BASE, SDFM_FILTER_4, SDFM_SYNC_PWM1_SOCA);

    //
    // Enable interrupts
    //
    // Following SDFM interrupts can be enabled / disabled using this function.
    // Enable  modulator clock failure
    // Enable  data filter acknowledge
    //

    SDFM_enableInterrupt(SDFM1_BASE, SDFM_FILTER_4, (SDFM_MODULATOR_FAILURE_INTERRUPT | SDFM_DATA_FILTER_ACKNOWLEDGE_INTERRUPT));

/*
    SDFM_disableInterrupt(SDFM1_BASE, SDFM_FILTER_4,
            (SDFM_HIGH_LEVEL_THRESHOLD_INTERRUPT |
             SDFM_LOW_LEVEL_THRESHOLD_INTERRUPT));
*/
    //
    // Enable master interrupt so that any of the filter interrupts can trigger
    // by SDFM interrupt to CPU
    //
    SDFM_enableMasterInterrupt(SDFM1_BASE);
}

Thank you.

  • Jozef,

    Whenever you get SDSYNC event from PWM1.SOCA every 20us, you are expected to get two incorrect samples for Sinc3 filter. This is expected behavior and is documented in TRM (Check SDSYNC Event section pg 1737). After 2 incorrect samples, you start getting correct samples from 3rd sample onwards.

    Regards,

    Manoj

  • Manoj,
    I am aware that first two samples are incorrect but I am continuously getting wrong samples. There should be another reason but I still can not find it.

    Regards,
    Jozef

  • Manoj,
    I read your comment one more time and I think I did not understand you well at the first time. 
    So, getting SDSYNC event every 20us does not make any sense once I have data rate frequency 78kHz  because I never get the third (correct) sample in 20us period. 
    Is that right? 

    Regards,

    Jozef

  • Jozef,

    Your data filter is operating at DOSR = 128 @ 20 MHz SDCLK with a data rate = 6.4 us and latency = 19.2 us.

    When SDSYNC event occurs at every 20 us, your data filter requires atleast 19.2us from SDSYNC event to start producing correct filter results. If you're reading data filter results without using AFx flag bit (or data acknowledge interrupt), you need to add additional 5 SDCLK cycles on top of latency of filter. So, you can only read filter result after 19.2 us + 250 ns = 19.45 us. So, you really have very little margin to read the filter results before subsequent SDSYNC event.

    You have only two options:

    1. Reduce the frequency of SDSYNC event (or)
    2. Reduce DOSR as a trade-off to have more bandwidth to read filter results before SDSYNC event.

    Regards,

    Manoj