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.

LAUNCHXL-F28379D: Trouble configuring ADC with F28379D & BOOSTXL-DRV8305EVM

Part Number: LAUNCHXL-F28379D
Other Parts Discussed in Thread: BOOSTXL-DRV8305EVM, DRV8305

Tool/software:

Good Morning! I'm attempting to setup the ADC but I'm struggling to get it to work correctly. All the values I am reading are the same, and when i put an oscilloscope onto the motor driver sense pins i do not seem to see a signal at all. Please see the attached code. 

#include "adc.h"
#include "adc_priv.h"

#include "..\other\adc.h"
#include "..\other\hw_ints.h"
#include "..\other\device.h"

COIL_FEEDBACK_TYPE Coil_Feedback;

void ConfigureAdc(void)
{
    EALLOW;
    //
    // Interrupts that are used in this example are re-mapped to ISR functions
    // found within this file.
    //
    Interrupt_register(INT_ADCA1, &adcA1ISR);

    //
    // Set up the ADC and the ePWM and initialize the SOC
    //
    InitAdc(ADCA_BASE);
    InitAdc(ADCB_BASE);
    InitAdc(ADCC_BASE);
    InitAdcSoc();

    EPWM_setADCTriggerSource(EPWM1_BASE, EPWM_SOC_A, EPWM_SOC_TBCTR_U_CMPA);
    //EPWM_setADCTriggerSource(EPWM1_BASE, EPWM_SOC_A, EPWM_SOC_TBCTR_ZERO_OR_PERIOD);
    EPWM_setADCTriggerEventPrescale(EPWM1_BASE, EPWM_SOC_A, 1);
    Interrupt_enable(INT_ADCA1);
    EPWM_enableADCTrigger(EPWM1_BASE, EPWM_SOC_A);
    EDIS;
}

void InitAdc(uint32_t adcBase)
{
    //
    // Set ADCDLK divider to /4
    //
    ADC_setPrescaler(adcBase, ADC_CLK_DIV_4_0);

    //
    // Set resolution and signal mode (see #defines above) and load
    // corresponding trims.
    //
#if(EX_ADC_RESOLUTION == 12)
    ADC_setMode(adcBase, ADC_RESOLUTION_12BIT, ADC_MODE_SINGLE_ENDED);
#elif(EX_ADC_RESOLUTION == 16)
    ADC_setMode(adcBase, ADC_RESOLUTION_16BIT, ADC_MODE_DIFFERENTIAL);
#endif

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

    //
    // Power up the ADCs and then delay for 1 ms
    //
    ADC_enableConverter(adcBase);

    //
    // Delay for 1ms to allow ADC time to power up
    //
    DEVICE_DELAY_US(1000);
}

//
// Function to configure SOCs on ADCA and ADCB to be triggered by ePWM1.
//
void InitAdcSoc(void)
{
    //
    // Select the channels to convert and the configure the ePWM trigger 
    //
    ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM1_SOCA,
                 ADC_CH_ADCIN14, ADC_SAMPLING_WINDOW);      // ADCIN14
    ADC_setupSOC(ADCC_BASE, ADC_SOC_NUMBER1, ADC_TRIGGER_EPWM1_SOCA,
                 ADC_CH_ADCIN3, ADC_SAMPLING_WINDOW);       // ADCINC3
    ADC_setupSOC(ADCA_BASE, ADC_SOC_NUMBER2, ADC_TRIGGER_EPWM1_SOCA,
                 ADC_CH_ADCIN3, ADC_SAMPLING_WINDOW);       // ADCINA3
    ADC_setupSOC(ADCC_BASE, ADC_SOC_NUMBER3, ADC_TRIGGER_EPWM1_SOCA,
                 ADC_CH_ADCIN2, ADC_SAMPLING_WINDOW);       // ADCINC2
    ADC_setupSOC(ADCB_BASE, ADC_SOC_NUMBER4, ADC_TRIGGER_EPWM1_SOCA,
                 ADC_CH_ADCIN2, ADC_SAMPLING_WINDOW);       // ADCINB2

    ADC_setInterruptSource(ADCA_BASE, ADC_INT_NUMBER1, ADC_SOC_NUMBER0);
    ADC_enableInterrupt(ADCA_BASE, ADC_INT_NUMBER1);
    ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);
}

__interrupt void adcA1ISR(void)
{
    Coil_Feedback.V_Sen_A_Raw = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER0);
    Coil_Feedback.V_Sen_B_Raw = ADC_readResult(ADCCRESULT_BASE, ADC_SOC_NUMBER1);
    Coil_Feedback.V_Sen_Pvdd_Raw = ADC_readResult(ADCARESULT_BASE, ADC_SOC_NUMBER2);
    Coil_Feedback.I_Sen_A_Raw = ADC_readResult(ADCCRESULT_BASE, ADC_SOC_NUMBER3);
    Coil_Feedback.I_Sen_B_Raw = ADC_readResult(ADCBRESULT_BASE, ADC_SOC_NUMBER4);

    Coil_Feedback.V_Sen_A = (U16)((F32)V_SEN_GAIN * Coil_Feedback.V_Sen_A_Raw);
    Coil_Feedback.V_Sen_B = (U16)((F32)V_SEN_GAIN * Coil_Feedback.V_Sen_B_Raw);
    Coil_Feedback.V_Sen_Pvdd = (U16)((F32)V_SEN_GAIN * Coil_Feedback.V_Sen_Pvdd_Raw);
    
    Coil_Feedback.Measured_Current = I_SEN_GAIN * ((F32)Coil_Feedback.I_Sen_A_Raw - Coil_Feedback.I_Sen_B_Raw);
    //
    // Clear the interrupt flag
    //
    ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);

    //
    // Check if overflow has occurred
    //
    if(true == ADC_getInterruptOverflowStatus(ADCA_BASE, ADC_INT_NUMBER1))
    {
        ADC_clearInterruptOverflowStatus(ADCA_BASE, ADC_INT_NUMBER1);
        ADC_clearInterruptStatus(ADCA_BASE, ADC_INT_NUMBER1);
    }

    //
    // Acknowledge the interrupt
    //
    Interrupt_clearACKGroup(INTERRUPT_ACK_GROUP1);
}

//
// End of file
//

  • Hello and apologies for the long delay in response,

    A few notes:

    • I don't see a main function here, or any PWM configurations, so I'm going to assume those are elsewhere.
    • I don't see any calls to the Interrupt_enable() function for the ISR, which enables the interrupt in the CPU after you've registered it in your ConfigureADC() function.
    • If you're not seeing any signal on the motor driver current sense pins, then it sounds like the ADC readings are correct- given the BOOSTXL-DRV8305EVM is a 3-shunt sensing board, I'm going to assume that the ADC results register for the current sensing pins reads all of them at or near 2048- the 3.3V offset point. I'm also going to say it's likely the motor isn't moving?
    • I'd take a look at your code to enable the DRV8305 and to run the motor/PWMs. Without further information on what exactly is happening with the motor, I can't give more specific advice.

    It seems to me like the 

  • No worries on the delay, my issue ended up being something completely different to what I posted here, thank you for the help though!