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.

CCS/PGA900EVM: pga900EVM

Part Number: PGA900EVM

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;

 

  • Hello,

    It really depends on how you would like to implement this. Everything here was just placed there as an example. In this case you are correct that the values don't actually accumulate how it is currently written. You could accumulate indefinitely, or you could accumulate a certain number of values before resetting back to 0.

    For example:

    if(TADC_AccIndex < 16)
           {
        	   FIR_AccadcValue[1] += (TADC_data_temp);		/* Accumulate 16 TADC Values for Temp. Calibration */
        	   TADC_AccIndex++;
           }
           else
           {
        	   TADC_AccValue = FIR_AccadcValue[1];
               FIR_AccadcValue[1] = 0;
               TADC_AccIndex = 0;

    Again, this is entirely up to you and your application. It will work fine with a single value.


    Regards,