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.

MSP430F6736: SD24 result data difference(has two level) with huge average once restart the MCU..

Part Number: MSP430F6736
Other Parts Discussed in Thread: MSP430WARE, MSP-EM-DESIGN-CENTER

Hello Champs,

One of my customer is considering to measure current using shunt resistor with MSP430F6736(or F6736A).

At this moment, they got an issue regarding SD24 as below.

<Environment>
- HW using 1phase EVM, SW using SD24 driver library example on the MSP430Ware and modified it.
- Source code : attached 
- Symptom : a single channel SD24 conversion result values are grouped with two value range when I repeat to collect the data and reset the MCU again and again.

- Detail explanation :
  - A result values averaged with more than 2,000~10,000 samples and saw data three times via break point using JTAG.
  - At this point these three data has under 2,000 gap.
  - But when I reset in the CCS and run again and saw the data after triggered break point, sometimes it has over 5,000 gap.
    For example, First sample average was 67092163, 67090965(1198 gap with first), 67090893(72 gap with 2nd average).
    But do the reset and check the second sample average, then 67100153, 67098878(1275 gap), 67099391(-513 gap) showed gap between 1st and 2nd sample over 7000.
  - It happens always when the condition SD24 input pins are open, short or some sort of level. 
  - This case, OSR : 512, GAIN : 16, Opened SD24 input pin.

- More comments
  1. When OSR was 512, the data range would be 0 ~ 2^27(-FSR ~ +FSR). The middle(0V) would be 67108864.
  2. With my calculation, value gap 4096 for the OSR 512 would be 1bit LSB difference at the 15bit.
  3. It is not improved with below actions
   - Change Gain, Main and Modulator Frequency, VREF as External 1.2~1.4V(using resistor dividor), SD24 input as open, short, connect shunt.

Would you please guide me if you have any experience regarding this or some idea?

Thank you. 


/* --COPYRIGHT--,BSD
 * Copyright (c) 2017, Texas Instruments Incorporated
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * *  Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * *  Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * *  Neither the name of Texas Instruments Incorporated nor the names of
 *    its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * --/COPYRIGHT--*/
//*****************************************************************************
//  MSP430F673x Demo - SD24_B, Continuous Conversion on a Single Channel
//
//  Description: This program uses the SD24_B module to perform continuous
//  conversions on a single channel. An SD24_B interrupt occurs when a
//  conversion has completed. Test by applying a voltage to channel 2
//  (SD2P0, SD2N0) and setting a breakpoint at the line indicated below.
//  Run program until it reaches the breakpoint, then use the debugger's
//  watch window to view the conversion results. Results (upper 16 bits only)
//  for channel 2 are stored in the array "results".
//  ACLK = n/a, MCLK = SMCLK = DCO =  ~ 1.1MHz
//  //* For Minimum Vcc required for SD24_B module - see datasheet          *//
//  //* 100nF cap between Vref and AVss is recommended when using 1.5V REF  *//
//
//                MSP430F673x
//             -----------------
//         /|\|              XIN|-
//          | |                 |
//          --|RST          XOUT|-
//            |                 |
//    Vin+ -->|SD2P0            |
//    Vin- -->|SD2N0            |
//            |                 |
//            |            VREF |---+
//            |                 |   |
//            |                 |  -+- 100nF
//            |                 |  -+-
//            |                 |   |
//            |            AVss |---+
//            |                 |
//
//  M. Swanson
//  Texas Instruments, Inc
//  December 2011
//  Built with CCS Version: 5.1.0 and IAR Embedded Workbench Version: 5.40.1
//*****************************************************************************

#include "driverlib.h"

#define Num_of_Results 100
#define Num_of_Results2 20

/* Array to store SD24_B conversion results */
uint32_t results[Num_of_Results];
uint64_t sum_result = 0;

uint64_t sum_result_arr[Num_of_Results2];

const uint32_t SystemCoreClock = (25ul * 1000 * 1000);

void main(void)
{
	 WDT_A_hold(WDT_A_BASE); // Stop WDT
     __disable_interrupt();

	// Select internal REF
    // Select SMCLK as SD24_B clock source
	SD24_B_initParam initParam = {0};
    initParam.clockSourceSelect = SD24_B_CLOCKSOURCE_SMCLK;
    initParam.clockPreDivider = SD24_B_PRECLOCKDIVIDER_1;
    initParam.clockDivider = SD24_B_CLOCKDIVIDER_1;
    initParam.referenceSelect = SD24_B_REF_EXTERNAL;    //SD24_B_REF_INTERNAL;
    SD24_B_init(SD24_BASE, &initParam);

	SD24_B_setInterruptDelay(SD24_BASE,
	 		SD24_B_CONVERTER_1,
	 		SD24_B_THIRD_SAMPLE_INTERRUPT);

//    SD24_B_setOversampling(SD24_BASE,
//            SD24_B_CONVERTER_1,
//            SD24_B_OVERSAMPLE_512);

//    SD24_B_setGain(SD24_BASE,
//            SD24_B_CONVERTER_1,
//            SD24_B_GAIN_16);



	 // Enable channel 2 interrupt
	SD24_B_clearInterrupt(SD24_BASE,
	 		SD24_B_CONVERTER_1,
	 		SD24_B_CONVERTER_INTERRUPT	);
	SD24_B_enableInterrupt(SD24_BASE,
	 		SD24_B_CONVERTER_1,
	 		SD24_B_CONVERTER_INTERRUPT	);

    __delay_cycles(0x3600);                 // Delay for 1.5V REF startup

    SD24_B_startConverterConversion(SD24_BASE,
    	1);								 // Set bit to start conversion

    __bis_SR_register(LPM0_bits | GIE);     // Enter LPM0 w/ interrupts
}

#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=SD24B_VECTOR
__interrupt
#elif defined(__GNUC__)
__attribute__((interrupt(SD24B_VECTOR)))
#endif
void SD24BISR(void)
{
    static uint16_t index = 0;
    static uint16_t index2 = 0;

    switch (SD24BIV)
    {
        case SD24BIV_SD24OVIFG:             // SD24MEM Overflow
            break;
        case SD24BIV_SD24TRGIFG:            // SD24 Trigger IFG
            break;
        case SD24BIV_SD24IFG0:              // SD24MEM0 IFG
            break;
        case SD24BIV_SD24IFG2:              // SD24MEM1 IFG
            break;
        case SD24BIV_SD24IFG1:              // SD24MEM2 IFG
            results[index] =  SD24_B_getResults(SD24_BASE,
                    SD24_B_CONVERTER_1);                            // Save CH1 results (clears IFG)
            sum_result += results[index];
            if (++index == Num_of_Results)
            {
                sum_result /= Num_of_Results;

                sum_result_arr[index2] = sum_result;
                if(++index2 == Num_of_Results2)
                {
                    index2 = 0;                  // SET BREAKPOINT HERE
                }

                index = 0;
                sum_result = 0;

            }
            break;
    }
}



  • Hello Ernest,

    If I'm understanding correctly, the issue is the the very first averaged sample form the SD ADC is off vs following measurements?  

    It sounds like this is a settling time issue.  Because they are just powering up, I imagine they are changing the analog input settings for the SD24.  Section 29.2.6.2 of the User's Guide specifices Analog Input Setup.  It states 

    User's Guide said:
    any modification of the SD24BINCTLx register becomes effective with the next decimation step of the digital filter. After these bits are modified, the next three conversions may be invalid due to the settling time of the digital filter. This can be handled automatically with the SD24INTDLYx bits. When SD24INTDLYx = 00b, conversion interrupt requests do not begin until the fourth conversion after a start condition

    Is this what they are seeing?

    Thanks,

    JD

  • Hello  JD.

    We modified Delay too. Conversion forth or third sample also have the same results.

    I think if you see the code and do what I did then you can understand  what I meant within 10min.

    Thank you.

    Ernest.

  • Hello team,
    Some improvements from my test. So some questions arise.

    I set SD24CAL bit to get the SD24 offset value, and then adjusted the value to the SD24 AD Results, so the over 5000 gap seems to be improved.

    Q : SD24CAL=1 is measuring offset of the converter which mentioned at the end of user guide 29.2.6.2.
    Is it only for internal voltage reference, not applicable for a external reference?
    Q : It should be calculated and calibrated without load, is it correct?

    Thanks,
    Ernest Cho
  • Hey Ernest,

    Ernest Cho said:
    Q : SD24CAL=1 is measuring offset of the converter which mentioned at the end of user guide 29.2.6.2.
    Is it only for internal voltage reference, not applicable for an external reference?

    My understanding is that it should work with either reference.  The Converter is referenced off of Vref, and Vref can be sourced either internally or externally.

    Ernest Cho said:
    Q : It should be calculated and calibrated without load, is it correct?

    I'm not sure if the load matters or not. The SD24CAL bit is connected to the PGA as well so I believe it won't be affected by the external load.  Below is the Block Diagram leading to believe this.  I will try and see if I can find any more information on this but it may be easier to test on your side.  

        

    Thanks,

    JD

      

  • Ernest,

    I also wanted to point you to the new Energy Measurement Design Center, MSP-EM-DESIGN-CENTER. You may already be aware, but this is a rapid development tool for the MSP430F67xx devices.

    Thanks,
    JD
  • Hey Ernest,

    Spoke with James and we both feel that the load should not matter.  

    Also, You could try adjusting the code to the fourth sample interrupt and seeing if that also improves these first measurement results.

    SD24_B_setInterruptDelay(SD24_BASE,
    	 		SD24_B_CONVERTER_1,
    	 		SD24_B_FOURTH_SAMPLE_INTERRUPT);

    Thanks,

    JD

**Attention** This is a public forum