SPRUHJ1I January 2013 – October 2021 TMS320F2802-Q1 , TMS320F28026-Q1 , TMS320F28026F , TMS320F28027-Q1 , TMS320F28027F , TMS320F28027F-Q1 , TMS320F28052-Q1 , TMS320F28052F , TMS320F28052F-Q1 , TMS320F28052M , TMS320F28052M-Q1 , TMS320F28054-Q1 , TMS320F28054F , TMS320F28054F-Q1 , TMS320F28054M , TMS320F28054M-Q1 , TMS320F2806-Q1 , TMS320F28062-Q1 , TMS320F28062F , TMS320F28062F-Q1 , TMS320F28068F , TMS320F28068M , TMS320F28069-Q1 , TMS320F28069F , TMS320F28069F-Q1 , TMS320F28069M , TMS320F28069M-Q1
On the other hand, Figure 6-6 represents a negative feedback. In this hardware configuration, the negative pin of the shunt resistor, which is connected to ground, is also connected to the noninverting pin of the operational amplifier. The code is shown below, a variable "current_sf" is positive in HAL_readAdcData( ) for noninverting operation. For negative feedback, the current offsets are positive in user.h. The lines of code shown below illustrate the offset in user.h. Functions HAL_readAdcData( ) is located in hal.h file; no change is needed in these functions also.
static inline void HAL_readAdcData(HAL_Handle handle,HAL_AdcData_t *pAdcData)
{
HAL_Obj *obj = (HAL_Obj *)handle;
_iq value;
_iq current_sf = HAL_getCurrentScaleFactor(handle);
_iq voltage_sf = HAL_getVoltageScaleFactor(handle);
// convert current A
// sample the first sample twice due to errata sprz342f, ignore the first sample
value = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_1);
value = _IQ12mpy(value,current_sf) - obj->adcBias.I.value[0]; // divide by 2^numAdcBits = 2^12
pAdcData->I.value[0] = value;
// convert current B
value = (_iq)ADC_readResult(obj->adcHandle,ADC_ResultNumber_2);
value = _IQ12mpy(value,current_sf) - obj->adcBias.I.value[1]; // divide by 2^numAdcBits = 2^12
pAdcData->I.value[1] = value;
#define I_A_offset (0.9902871847)
#define I_B_offset (0.9889662266)
#define I_C_offset (0.9897354245)