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.

ADC initialization program



Hi Team,

The customer needs to explain the ADC initialization program in the motor control FCL routine

void FCL_initADC_3In(MOTOR_Vars_t *gsMC, const uint32_t adcBaseW,
const uint32_t adcResultBaseU, ADC_PPBNumber adcU_PPBNum,
const uint32_t adcResultBaseV, ADC_PPBNumber adcV_PPBNum,
const uint32_t adcResultBaseW, ADC_PPBNumber adcW_PPBNum )
{
uint16_t adcPPBCurU, adcPPBCurV, adcPPBCurW;

adcPPBCurU = (uint16_t)(ADC_PPBxRESULT_OFFSET_BASE +(uint16_t)adcU_PPBNum * 2);
adcPPBCurV = (uint16_t)(ADC_PPBxRESULT_OFFSET_BASE +(uint16_t)adcV_PPBNum * 2);
adcPPBCurW = (uint16_t)(ADC_PPBxRESULT_OFFSET_BASE +(uint16_t)adcW_PPBNum * 2);

gsMC->curA_PPBRESULT = adcResultBaseU + adcPPBCurU;
gsMC->curB_PPBRESULT = adcResultBaseV + adcPPBCurV;
gsMC->curC_PPBRESULT = adcResultBaseW + adcPPBCurW;

gsMC->curA_resultBase = adcResultBaseU;
gsMC->curB_resultBase = adcResultBaseV;
gsMC->curC_resultBase = adcResultBaseW;

gsMC->curA_PPBNumber = adcU_PPBNum;
gsMC->curB_PPBNumber = adcV_PPBNum;
gsMC->curC_PPBNumber = adcW_PPBNum;

gsMC->AdcIntFlag = (union ADCINTFLG_REG *)(adcBaseW + ADC_O_INTFLG);

return;
}

Annie

  • These are all pointer variables. Pointers are used extensively to make the program modular. Since they all have the same structure, basic register address definitions can be made in one place and then passed to various functions using these pointer variables.

    adcPPBCurU ===> address of PPB of ADC connected to phase current U read

    gsMC->curA_PPBRESULT ===> pointer holding address of current A PPBRESULT register

    gsMC->curA_resultBase ===> pointer holding base address of result register associated with phase current A

    gsMC->curA_PPBNumber ===>  stores PPB number of ADC associated to phase current A 

  • Thanks for your response.

    Customer also would like to know:

    1. What does the expression here multiply by 2 mean?

    adcPPBCurU = (uint16_t)(ADC_PPBxRESULT_OFFSET_BASE +(uint16_t)adcU_PPBNum * 2);
    adcPPBCurV = (uint16_t)(ADC_PPBxRESULT_OFFSET_BASE +(uint16_t)adcV_PPBNum * 2);
    adcPPBCurW = (uint16_t)(ADC_PPBxRESULT_OFFSET_BASE +(uint16_t)adcW_PPBNum * 2);

    2. Because of FOC control, the required input is a three-phase current, which is converted from the above quantities? The above program is in FCL (Fast Current Loop). Can the low-level functions configured by the customer with registers be able to use FCL library functions? How to better connect this part?

    Thanks,

    Annie

  • 1. What does the expression here multiply by 2 mean?

    adcPPBCurU = (uint16_t)(ADC_PPBxRESULT_OFFSET_BASE +(uint16_t)adcU_PPBNum * 2);

    This register size is two memory locations, so the next register address will be after these two. 

    Can the low-level functions configured by the customer with registers be able to use FCL library functions? How to better connect this part?

    Yes, they can. The source code is all open and they will have to edit the functions to address this issue. We do not have any notes to refer to. Since the source code is all open, they should be able to tweak it to suit their preference.

  • Hi ,

    Customer would like to know does TI have any guidance documents on motor library functions? He feels that library functions are more obscure and difficult to understand.

    Thanks,

    Annie

  • No, but it is not that complex. If they can spend some time to dig through the code, they can figure it out.