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.

TMS320F280049: SOC cannot trigger ADC

Part Number: TMS320F280049

Hi team,

I am helping my customer debugging their S/W.

The cdoe is pretty simple, the use EPWM1 SOCA to trigger ADCA CH0.

Here is their PWM setting, and I can observe a SOCA flag in CCS:

    EPWM_disableADCTrigger(EPWM1_BASE, EPWM_SOC_A);
    EPWM_setADCTriggerSource(EPWM1_BASE, EPWM_SOC_A, EPWM_SOC_TBCTR_U_CMPA);
    EPWM_setADCTriggerEventPrescale(EPWM1_BASE, EPWM_SOC_A, 3);
    EPWM_enableADCTrigger(EPWM1_BASE, EPWM_SOC_A);

And here ADC SOC configuration. Everything seems right, but no SOC is triggered.

    ADC_setVREF(ADCA_BASE, ADC_REFERENCE_EXTERNAL, ADC_REFERENCE_3_3V);

    //
    // Set ADCCLK divider to /4
    //
    ADC_setPrescaler(ADCA_BASE, ADC_CLK_DIV_4_0);

    //
    // Set pulse positions to late
    //
    ADC_setInterruptPulseMode(ADCA_BASE, ADC_PULSE_END_OF_CONV);

    //
    // Power up the ADC and then delay for 1 ms
    //

    ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM1_SOCA,
                 ADC_CH_ADCIN0, 10);

    ADC_enableConverter(ADCA_BASE);
    DEVICE_DELAY_US(1000);

Regards,

Brian

  • Just to clarify, are you seeing the Flag for SOC trigger get set or not?

  • Hi Nima,

    As you can see I the first picture, the PWM SOC flag is set. But the ADC flag is not

  • Here is a working code I have,

    There must be a minor change between the two causing this!

        #define ADC_EPWM    EPWM7_BASE
    
        //
        // Setup VREF as external as required by the temperature sensor. Note that
        // the refVoltage parameter has no effect in this case.
        //
        ADC_setVREF(ADCA_BASE, ADC_REFERENCE_INTERNAL, ADC_REFERENCE_3_3V);
    
        //
        // Set ADCCLK divider to /4
        //
        ADC_setPrescaler(ADCA_BASE, ADC_CLK_DIV_4_0);
    
        //
        // Set pulse positions to late
        //
        ADC_setInterruptPulseMode(ADCA_BASE, ADC_PULSE_END_OF_CONV);
    
        //
        // Power up the ADC and then delay for 1 ms
        //
        ADC_enableConverter(ADCA_BASE);
        DEVICE_DELAY_US(1000);
    
        //
        // Disable SOCA
        //
        EPWM_disableADCTrigger(ADC_EPWM, EPWM_SOC_A);
    
        //
        // Configure the SOC to occur on the first up-count event
        //
        EPWM_setADCTriggerSource(ADC_EPWM, EPWM_SOC_A, EPWM_SOC_TBCTR_U_CMPA);
        EPWM_setADCTriggerEventPrescale(ADC_EPWM, EPWM_SOC_A, 1);
    
        //
        // Set the compare A value to 2048 and the period to 4096
        //
        EPWM_setCounterCompareValue(ADC_EPWM, EPWM_COUNTER_COMPARE_A, 500);
        EPWM_setTimeBasePeriod(ADC_EPWM, 1000);
    
        //
        // Freeze the counter
        //
        EPWM_setTimeBaseCounterMode(ADC_EPWM, EPWM_COUNTER_MODE_STOP_FREEZE);
    
        ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM7_SOCA,
                     ADC_CH_ADCIN5, 100);
    
        //
        // Set SOC0 to set the interrupt 1 flag. Enable the interrupt and make
        // sure its flag is cleared.
        //
        ADC_setInterruptSource(ADCA_BASE, ADC_INT_NUMBER1, ADC_SOC_NUMBER0);
    
        ADC_enableInterrupt(ADCA_BASE, ADC_INT_NUMBER1);
        ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);
    
    
    uint32_t num = 0;
    __interrupt void adcA1ISR(void)
    {
        //
        // Read the raw result
        //
        //Read value = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER0);
    
        //
        // Clear the interrupt flag and issue ACK
        //
        ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);
        Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
    }
    
    

  • Thanks Nima,

    I would look into more details to see what is happening!