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.

Sigma Delta ADC

Other Parts Discussed in Thread: MSP430F427

I am using MSP430F427 which has 3 channels of 16 bit sigma delta ADC.

A sample application software from TI shows how to use this SD16 with an ISR.

I compiled the software source using CCS version 4, and downloaded it to the target board with LCD display.

The target board ADC output is displaced on the LCD.  The ADC results seem like a random noise - it is changing continuously and very widely.

I monitored the output parameter "CurrentResult" that is a "long" type variable.  It does not seem right.

For your information, I copy and paste the TI sample code as follows:

#pragma vector = SD16_VECTOR
__interrupt void SD16_ISR(void)
{
  long CurrentResult;

  GET_RESULT(CurrentResult);                    // Read SD16 result, clear IFG

  if (VoltageSettleCtr)                         // Wait for voltages to settle
  {
    VoltageSettleCtr--;                         // Decrement counter
    return;                                     // Exit ISR

  }

  SD16Temp += CurrentResult;                    // Sum up results

  if (++SD16TempCtr >= 256)
  {
    SD16Result = SD16Temp >> 8;                 // Div 256
    SD16CCTL0 &= ~SD16SC;                       // Disable conversions
    P2OUT &= ~BRIDGE_SUPPLY;                    // Power down bridge voltage

    if (ProgramMode == PM_MEASURE)
      if (Flags & FLAG_UPDATE_DISPL || LastADCValue != SD16Result)
      {
        Flags &= ~FLAG_UPDATE_DISPL;            // Reset flag
        LastADCValue = SD16Result;              // Store new value

        Disp_Signed_Long(((long)SD16Result - CalMin) * CAL_MIN_MAX_SPAN /
                        (CalMax - CalMin));
      }

    __bis_SR_register_on_exit(LPM3_bits);       // Enter LPM3 on ISR exit
  }
}

 

Can you give me some suggestions how to setup and debug the SD16 ISR using CCS V4?

  • You are just passing the variable ‘CurrentResult’ to the function GET_RESULT without getting anything back. You need to point to CurrentResult;

    Function:

    void GET_RESULT(long *CurrentResult)

    {…}

     

    and call:

                GET_RESULT(&CurrentResult);

     

     

    -Leo

  • If GET_RESULT is a funciton, then indeed the variable should be passed by reference. But from the name (all uppercase) I rather guess t is a macro, whose parameter can well be used as an lvalue:

    #define ASSIGN(x,y) y=x;

    Also, function calls inside an ISR should be avoided as they hinder optimization, cause registers to be clobbered (which need ot be saved and restored then) and add to the execution time for the call itself and the funciton-internal frame (e.g. redundant register saving etc.)

    Also, things like externsive calculations and transferring data to a display shouldn't be inside an ISR.

    Without knowing main() I cannot say whether there are logical problems.
    __bis_SR_register_on_exit is rather uncommon. It effectively stops the execution of main() by this interrupt (what was main doing before?). The more usual setup is that main() enters LPM and the ISR calls __bic_SR_on_exit() to make main() continue after a certain event.

    In this case, I would expect that main() initialized the reading and then goes to sleep until a result is ready. Once ++SD16TempCtr is >=256 (SD16TempCtr and all other globals used in main as well as inside an ISR should be volatile!), the ISR wakes main() and the calculation and display is done inside main() after wakeup.

    Also, after 256 values, you stop the conversion, so no more values are coming. And since main is stopped, I wonder what will cause it to display more than one value? is there another ISR that wakes main up again? Or is bic/bis a typo?

**Attention** This is a public forum