AnsweredAssumed Answered

About S32 project of the Dual motor control Demo board,I  have a qusetion about the ADC

Question asked by Eden Li on Jun 28, 2017
Latest reply on Jul 1, 2017 by Eden Li

Hi Guys,

dumitru-daniel.popaPetr Fajmon

I down load the MTRCKTDPS5643L Application Software,and i use the S32 Design Studio for Power Architecture v1.1 to open it,There is a piece of code shown:

 

tBool ADC_Measure2Ph(pmsmDrive_t *ptr)
{
switch(ptr->svmSector)
{
case 2:
case 3:
{
ptr->adc.measured.fltPhA.raw = (tFloat)((ioctl(ptr->uni3PeriphCfg.PhABaseAddr,ADC_READ_VALUE, ptr->uni3PeriphCfg.PhAChnlOffset)));
ptr->adc.measured.fltPhC.raw = (tFloat)((ioctl(ptr->uni3PeriphCfg.PhCBaseAddr,ADC_READ_VALUE, ptr->uni3PeriphCfg.PhCChnlOffset)));
ptr->adc.measured.fltUdcb.raw = (tFloat)((ioctl(ptr->uni3PeriphCfg.UdcBaseAddr,ADC_READ_VALUE, ptr->uni3PeriphCfg.UdcChnlOffset)));

ptr->iAbcFbck.fltArg1 = MLIB_Mul(MLIB_Sub(ptr->adc.offset[ptr->svmSector].fltPhA,ptr->adc.measured.fltPhA.raw),2);
ptr->iAbcFbck.fltArg3 = MLIB_Mul(MLIB_Sub(ptr->adc.offset[ptr->svmSector].fltPhC,ptr->adc.measured.fltPhC.raw),2);
ptr->iAbcFbck.fltArg2 = MLIB_Neg(MLIB_Sub(ptr->iAbcFbck.fltArg1,ptr->iAbcFbck.fltArg3));
return(1);
}
case 4:
case 5:
{
ptr->adc.measured.fltPhA.raw = (tFloat)((ioctl(ptr->uni3PeriphCfg.PhABaseAddr,ADC_READ_VALUE, ptr->uni3PeriphCfg.PhAChnlOffset)));
ptr->adc.measured.fltPhB.raw = (tFloat)((ioctl(ptr->uni3PeriphCfg.PhBBaseAddr,ADC_READ_VALUE, ptr->uni3PeriphCfg.PhBChnlOffset)));
ptr->adc.measured.fltUdcb.raw = (tFloat)((ioctl(ptr->uni3PeriphCfg.UdcBaseAddr,ADC_READ_VALUE, ptr->uni3PeriphCfg.UdcChnlOffset)));

ptr->iAbcFbck.fltArg1 = MLIB_Mul(MLIB_Sub(ptr->adc.offset[ptr->svmSector].fltPhA,ptr->adc.measured.fltPhA.raw),2);
ptr->iAbcFbck.fltArg3 = MLIB_Mul(MLIB_Sub(ptr->adc.offset[ptr->svmSector].fltPhB,ptr->adc.measured.fltPhB.raw),2);
ptr->iAbcFbck.fltArg2 = MLIB_Neg(MLIB_Sub(ptr->iAbcFbck.fltArg1,ptr->iAbcFbck.fltArg2));

return(1);
}
case 1:
case 6:
default:
{
ptr->adc.measured.fltPhB.raw = (tFloat)((ioctl(ptr->uni3PeriphCfg.PhBBaseAddr,ADC_READ_VALUE, ptr->uni3PeriphCfg.PhBChnlOffset)));
ptr->adc.measured.fltPhC.raw = (tFloat)((ioctl(ptr->uni3PeriphCfg.PhCBaseAddr,ADC_READ_VALUE, ptr->uni3PeriphCfg.PhCChnlOffset)));
ptr->adc.measured.fltUdcb.raw = (tFloat)((ioctl(ptr->uni3PeriphCfg.UdcBaseAddr,ADC_READ_VALUE, ptr->uni3PeriphCfg.UdcChnlOffset)));

ptr->iAbcFbck.fltArg1 = MLIB_Mul(MLIB_Sub(ptr->adc.offset[ptr->svmSector].fltPhB,ptr->adc.measured.fltPhB.raw),2);
ptr->iAbcFbck.fltArg3 = MLIB_Mul(MLIB_Sub(ptr->adc.offset[ptr->svmSector].fltPhC,ptr->adc.measured.fltPhC.raw),2);
ptr->iAbcFbck.fltArg2 = MLIB_Neg(MLIB_Sub(ptr->iAbcFbck.fltArg2,ptr->iAbcFbck.fltArg3));

return(1);
}
}
}

 

And i   right click the mouse,and jump to code as below:

 

/*------------------------------------------------------------------------*//*!
@brief Structure containing list of base addresses and offsets of particular
channel related to UNI3 connector and to PMSM application
*//*-------------------------------------------------------------------------*/
typedef struct
{
tS32 PhABaseAddr; // Phase A current analog input - ADC Base address
tS16 PhAChnlOffset; // Phase A current analog input - ADC channel offset
tS32 PhBBaseAddr; // Phase B current analog input - ADC Base address
tS16 PhBChnlOffset; // Phase B current analog input - ADC channel offset
tS32 PhCBaseAddr; // Phase C current analog input - ADC Base address
tS16 PhCChnlOffset; // Phase C current analog input - ADC channel offset
tS32 UdcBaseAddr; // Udc bus voltage analog input - ADC Base address
tS16 UdcChnlOffset; // Udc bus voltage analog input - ADC channel offset
tU16 alignCntr; // Alignment counter variable
tFloat alignVoltage;
tS32 flexPwmBaseAddr; // flexPWM Base address related to UNI3 connector
}uni3PeriphCfgPmsm_t;

 

There is a qusetion that how the define of PhABaseAddr link to the ADC Base address?

Outcomes