SPRUJ26A September 2021 – April 2024
Similar to the previous PWM section, the ADC connections can also be changed for a custom board or a TI motor control kit or C2000 MCU that is not supported with the universal motor control lab. The HAL module configures the ADC channels to correctly correspond with the motor driver board. As an example, the connection diagram for the LAUNCHXL-F280025C and BOOSTXL-DRV8323RS combination is shown in Figure 4-3. The ADC modules configuration is described in the following steps, with potential board-specific changes highlighted in bold. Steps 1 and 2 are essential for configuring a new motor driver board or a different C2000 MCU to run the motor.
The code below is taken from the hal.h and hal.c files located in the solutions\universal_motorcontrol_lab\f28002x\drivers\include and \source folders.
#define MTR1_IU_ADC_BASE ADCA_BASE // ADCA-A11*/C0
#define MTR1_IV_ADC_BASE ADCC_BASE // ADCC-A14/C4*
#define MTR1_IW_ADC_BASE ADCC_BASE // ADCC-A15/C7*
#define MTR1_VU_ADC_BASE ADCA_BASE // ADCA-A6*
#define MTR1_VV_ADC_BASE ADCA_BASE // ADCC-A3*/C5
#define MTR1_VW_ADC_BASE ADCC_BASE // ADCA-A2/C9*
#define MTR1_VDC_ADC_BASE ADCC_BASE // ADCC-C6*
#define MTR1_POT_ADC_BASE ADCA_BASE // ADCA-A12*/C1
#define MTR1_IU_ADCRES_BASE ADCARESULT_BASE // ADCA-A11*/C0
#define MTR1_IV_ADCRES_BASE ADCCRESULT_BASE // ADCC-A14/C4*
#define MTR1_IW_ADCRES_BASE ADCCRESULT_BASE // ADCC-A15/C7*
#define MTR1_VU_ADCRES_BASE ADCARESULT_BASE // ADCA-A6*
#define MTR1_VV_ADCRES_BASE ADCARESULT_BASE // ADCC-A3*/C5
#define MTR1_VW_ADCRES_BASE ADCCRESULT_BASE // ADCA-A2/C9*
#define MTR1_VDC_ADCRES_BASE ADCCRESULT_BASE // ADCC-C6*
#define MTR1_POT_ADCRES_BASE ADCARESULT_BASE // ADCA-A12*/C1
#define MTR1_IU_ADC_CH_NUM ADC_CH_ADCIN11 // ADCA-A11*/C0
#define MTR1_IV_ADC_CH_NUM ADC_CH_ADCIN4 // ADCC-A14/C4*
#define MTR1_IW_ADC_CH_NUM ADC_CH_ADCIN7 // ADCC-A15/C7*
#define MTR1_VU_ADC_CH_NUM ADC_CH_ADCIN6 // ADCA-A6*
#define MTR1_VV_ADC_CH_NUM ADC_CH_ADCIN3 // ADCC-A3*/C5
#define MTR1_VW_ADC_CH_NUM ADC_CH_ADCIN9 // ADCA-A2/C9*
#define MTR1_VDC_ADC_CH_NUM ADC_CH_ADCIN6 // ADCC-C6*
#define MTR1_POT_ADC_CH_NUM ADC_CH_ADCIN12 // ADCA-A12*/C1
#define MTR1_IU_ADC_SOC_NUM ADC_SOC_NUMBER1 // ADCA-A11*/C10-SOC1-PPB1
#define MTR1_IV_ADC_SOC_NUM ADC_SOC_NUMBER1 // ADCC-A14/C4* -SOC1-PPB1
#define MTR1_IW_ADC_SOC_NUM ADC_SOC_NUMBER2 // ADCC-A15/C7* -SOC2-PPB2
#define MTR1_VU_ADC_SOC_NUM ADC_SOC_NUMBER4 // ADCA-A6* -SOC4
#define MTR1_VV_ADC_SOC_NUM ADC_SOC_NUMBER5 // ADCC-A3*/C5 -SOC5
#define MTR1_VW_ADC_SOC_NUM ADC_SOC_NUMBER5 // ADCA-A2/C9* -SOC5
#define MTR1_VDC_ADC_SOC_NUM ADC_SOC_NUMBER6 // ADCC-C6* -SOC6
#define MTR1_POT_ADC_SOC_NUM ADC_SOC_NUMBER6 // ADCA-A12*/C1 -SOC6
#define MTR1_IU_ADC_PPB_NUM ADC_PPB_NUMBER1 // ADCA-A11*/C10-SOC1-PPB1
#define MTR1_IV_ADC_PPB_NUM ADC_PPB_NUMBER1 // ADCC-A14/C4* -SOC1-PPB1
#define MTR1_IW_ADC_PPB_NUM ADC_PPB_NUMBER2 // ADCC-A15/C7*- SOC2-PPB2
// interrupt
#define MTR1_PWM_INT_BASE MTR1_PWM_U_BASE // EPWM1
#define MTR1_ADC_INT_BASE ADCA_BASE // ADCA-A14 -SOC4
#define MTR1_ADC_INT_NUM ADC_INT_NUMBER1 // ADCA_INT1-SOC4
#define MTR1_ADC_INT_SOC ADC_SOC_NUMBER4 // ADCA_INT1-SOC4
#define MTR1_PIE_INT_NUM INT_ADCA1 // ADCA_INT1-SOC4
#define MTR1_INT_ACK_GROUP INTERRUPT_ACK_GROUP1 // ADCA_INT1-CPU_INT1
// POT_M1 ADC_setupSOC(MTR1_POT_ADC_BASE, MTR1_POT_ADC_SOC_NUM, MTR1_ADC_TRIGGER_SOC, MTR1_POT_ADC_CH_NUM, MTR1_ADC_V_SAMPLEWINDOW);
// read POT adc value
pADCData->potAdc = ADC_readResult(MTR1_POT_ADCRES_BASE, MTR1_POT_ADC_SOC_NUM);