Tool/software: Code Composer Studio
/* ========================================================================== */
interrupt void PADC_Handler(void)
{
#if (ADC_24_BIT_TESTING == 1)
signed long xx,yy;
xx = (PADC_DATA_24BIT & 0x00FFFFFF);/* Mask the upper 8 bits */
if(xx & 0x00800000) /* If sign bit is set */
{
xx = xx | 0xFF000000; /* Sign extend the sign bit */
}
yy = (TADC_DATA_24BIT & 0x00FFFFFF);/* Mask the upper 8 bits */
if(yy & 0x00800000) /* If sign bit is set */
{
yy = yy | 0xFF000000; /* Sign extend the sign bit */
}
#else
SL coeffP;
ADC_Count1++;
/* Accumulate the value of P channel */
FIR_AccadcValue[0] = PADC_DATA;
/* Accumulate the value of T channel */
FIR_AccadcValue[1] += TADC_DATA;
/* Update DAC with previous value */
if (FaultDiag == 0)
{
DAC_REG0 = DAC_Value;
}
else if (FaultDiag == 1)
{
DAC_REG0 = 0x0000;
}
else if (FaultDiag == 2)
{
DAC_REG0 = 0x0FFF;
}
/*
* Application specific Pcoefficient Calculation
* Dn = H + G * PADC/2^14 + N * (PADC/2^14)^2
* DAC = Dn
* Please refer compensation algorithm document.
*/
coeffP = (NtempCoeff[VarI] * FIR_AccadcValue[0]);
coeffP = (coeffP >> 14);
coeffP = coeffP + GtempCoeff[VarI];
coeffP = (coeffP * FIR_AccadcValue[0]);
coeffP = (coeffP >> 14);
coeffP = coeffP + HtempCoeff[VarI];
DAC_Value = (US)(coeffP);
#endif
}
This is a example of PGA900 Generic Firmware .ADC Interrupt get ad and pass it's value to second order function.what the red code mean? why that code is not as follow?
example 1:
/* Accumulate the value of P channel */
FIR_AccadcValue[0] = PADC_DATA;
/* Accumulate the value of T channel */
FIR_AccadcValue[1] = TADC_DATA;
example 2:
/* Accumulate the value of P channel */
FIR_AccadcValue[0] += PADC_DATA;
/* Accumulate the value of T channel */
FIR_AccadcValue[1] += TADC_DATA;