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/TMS320F28379D: drv8301

Part Number: TMS320F28379D
Other Parts Discussed in Thread: DRV8301, DRV8305

Tool/software: Code Composer Studio

I am working with mono_servo motor control example which is available in control suite,some of the code is not very clear. Thanks for helping explain them

void InitMotor1_DRV_Gpio(void)
{
// Configure as Output : Motor 1 - EN-GATE
GPIO_WritePin(MOTOR1_EN_GATE_GPIO, 0); // Disable EN_GATE
GPIO_SetupPinOptions(MOTOR1_EN_GATE_GPIO, GPIO_OUTPUT, GPIO_ASYNC);
GPIO_SetupPinMux(MOTOR1_EN_GATE_GPIO, 0, MOTOR1_EN_GATE_MUX);

#if (DRV_MOTOR1 == DRV8301)
// Configure as Output : Motor 1 - DC-CAL for DRV8301
GPIO_WritePin(MOTOR1_DC_CAL_GPIO, 1); // Set DC-CAL to 1 to disable amplifiers
GPIO_SetupPinOptions(MOTOR1_DC_CAL_GPIO, GPIO_OUTPUT, GPIO_ASYNC);
GPIO_SetupPinMux(MOTOR1_DC_CAL_GPIO, 0, MOTOR1_DC_CAL_MUX);
#else
// Configure as Output : Motor 1 - WAKE for DRV8305
GPIO_WritePin(MOTOR1_WAKE_GPIO, 0); // Set WAKE to 0 (default state)
GPIO_SetupPinOptions(MOTOR1_WAKE_GPIO, GPIO_OUTPUT, GPIO_ASYNC);
GPIO_SetupPinMux(MOTOR1_WAKE_GPIO, 0, MOTOR1_WAKE_MUX);
#endif
}

why disable the EN_GATE and Set DC-CAL to 1 to disable amplifiers?

  • also in F2837xS_IO_assignment.h,  Some GPIO ports are defined differently from annotations

    the annotation is:

    /******************************************************************************
    Peripheral Assignments:
    MOTOR 1:
    - EPWMs ==>> EPWM7, EPWM8, EPWM9 ---> A, B, C
    - QEP ==>> EQep1
    - SPI ==>> Spia

    Analog signals - Motor 1
    Vdc ADC 14
    Va ADC B1
    Vb ADC B4
    Vc ADC B2
    Ia ADC A0
    Ib ADC B0
    Ic ADC A1

    ******************************************************************************/

    and the code is:

    #define IFB_A1 AdcaResultRegs.ADCRESULT0
    #define IFB_B1 AdcbResultRegs.ADCRESULT0
    #define IFB_C1 AdcaResultRegs.ADCRESULT2
    #define IFB_A1_PPB ((signed int)AdcaResultRegs.ADCPPB1RESULT.all)
    #define IFB_B1_PPB ((signed int)AdcbResultRegs.ADCPPB1RESULT.all)
    #define IFB_C1_PPB ((signed int)AdcaResultRegs.ADCPPB3RESULT.all)

    #if (MOTOR1_DRV == DRV8301)
    #define VFB_A1 AdcbResultRegs.ADCRESULT4
    #define VFB_B1 AdcbResultRegs.ADCRESULT3
    #define VFB_C1 AdcbResultRegs.ADCRESULT2
    #define VFB_DC1 AdcbResultRegs.ADCRESULT6

     

     

  • Reg GPIOs, this code attempts to setup the GPIO pin for a certain configuration such as input or output, sync or async, etc. Suggest to review the chapter GPIO in the TRM. Instead of using bit field programming directly, this approach does the same job using API approach. You can rewrite it.

    Reg ADCs, for example,

    Phase current A is available at ADC A0

    and the result register to read phase current A will be AdcaResultRegs.ADCRESULT0

    This is what is given in the .h file as

    Ia ADC A0

    #define IFB_A1 AdcaResultRegs.ADCRESULT0

    Macros in IO assignment.h are to avoid direct referencing of the peripheral register in the middle of a code. By having macros, it is easier to port the code to a different hardware platform by changing them in the .h file one time instead of multiple times in the actual code.