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.

MSP430FR5949: The equipment field operation has a small probability, ADC12 conversion results over 4095, up to more than 50000

Part Number: MSP430FR5949
Other Parts Discussed in Thread: STRIKE

#define CALADC12_25V_30C  *((unsigned int *)0x1A22)   // Temperature Sensor Calibration-30 C
#define CALADC12_25V_85C  *((unsigned int *)0x1A24)  //See device datasheet for TLV table memory mapping


void ADC_ui(void)
{
  REFCTL0 |= REFTCOFF;//
  ADC12CTL3 &=~ ADC12TCMAP;
  ADC12CTL0 |=ADC12SHT0_2;
  ADC12MCTL0 = ADC12VRSEL_1+ADC12INCH_12; // ref+=AVcc, channel = A2
  ADC12MCTL1 = ADC12VRSEL_1+ADC12INCH_14; // ref+=AVcc, channel = A4
  ADC12MCTL2 = ADC12VRSEL_1+ADC12INCH_4+ADC12EOS;
  ADC12IER0 = 0x04;                      // Enable ADC12IFG.3
}

void ADC_all(void)
{
  All_over=1;
  REFCTL0 &=~ REFTCOFF;
  ADC12CTL0 |= ADC12SHT0_8;
  ADC12CTL3 |= ADC12TCMAP;
  ADC12MCTL0 = ADC12VRSEL_1+ADC12INCH_12;//  P3.0-A12 
  ADC12MCTL1 = ADC12VRSEL_1+ADC12INCH_14;//  P3.2-A14
  ADC12MCTL2 = ADC12VRSEL_1+ADC12INCH_4;//   P1.4-A4
  ADC12MCTL3 = ADC12VRSEL_1+ADC12INCH_2;//   P1.2-A2
  ADC12MCTL4 = ADC12VRSEL_1+ADC12INCH_30+ADC12EOS;//
  ADC12IER0 = 0x10;                       // Enable      
}


#define  TIME_SAMPLE  (u16)(round)(32768/(1000.0/20)-1) 

void ADC_init(void)
{    
  P1SEL1 |= BIT1+BIT2+BIT4; //ref+ BAT 
  P1SEL0 |= BIT1+BIT2+BIT4;
  
  P2SEL1 |= BIT4; //C+
  P2SEL0 |= BIT4;
  
  P3SEL1 |= (BIT0+BIT1+BIT2);//isk ilk vol
  P3SEL0 |= (BIT0+BIT1+BIT2);//
  
  while(REFCTL0 & REFGENBUSY);
  REFCTL0 = REFVSEL_2;// | REFON;
  //while(REFCTL0 & REFGENRDY);//Reference voltage output is ready to be used
  
  ADC12CTL0 &= ~ADC12ENC;
  ADC12CTL0 |= ADC12ON|ADC12MSC; //          // Turn on ADC12, set sampling time
  ADC12CTL1 |= ADC12SHP|ADC12SHS_1| ADC12CONSEQ_1; //CSTARTADD_0++                // Use sampling timer, single sequence
  //ADC12CTL2 |= ADC12RES_2|ADC12PWRMD;                 // 12-bit conversion results
  ADC_ui();
  ADC12CTL0 |= ADC12ENC;
  
  TA0CCR0 = TIME_SAMPLE;//20ms      // PWM Period
  TA0CCR1 = TIME_SAMPLE;//20ms;     // TACCR1 PWM Duty Cycle
  TA0CCTL1 = OUTMOD_3;              // TACCR1 set/reset
  TA0CTL = TASSEL__ACLK | MC__UP;   // ACLK, up mode     
}


#pragma vector=ADC12_VECTOR
__interrupt void ADC12_ISR(void)
{
  LPM3_EXIT;   
  Vol_RT   = ADC12MEM0; //vol
  Isk   =  ADC12MEM1;   //isk
  Ilk   =  ADC12MEM2;   //ilk
  u16 bat_ad = ADC12MEM3; //BAT
  u16 temp_ad  = ADC12MEM4;//TEMP
  if(All_over==1)
  {   
    All_over=2;     
    BATVAL= ((u32)bat_ad*8375/40950);//BATVAL 2.5/2*6.7*100
    //ChargeVAL =((u32)charge_ad*8375/40950);     
    temper = (s16)((((long)temp_ad - CALADC12_25V_30C) * (85 - 30)) /
                  (CALADC12_25V_85C - CALADC12_25V_30C) + 30.0f);
  }
  ADC_start();
  for(u8 i=0;i<=5;i++) {
    NOP();
  }
  SysF.TIMA=1;
  TA_task();
}

void ADC_start(void)
{ 
  ADC12CTL0 &=~ ADC12ENC;
  static u8 All_sample_last=0;
  if(All_sample_last!=All_sample)
  {
    All_sample_last=All_sample;
    if(All_sample==1)
    {
      All_sample=0;
      ADC_all(); //5 channels
    }
    else
    {
      ADC_ui(); //3 channels
    }
  }
  ADC12CTL0 |= ADC12ENC; 
}

During field operation, ADC conversion result is abnormal with small probability, exceeding 50000.

error condition:

   Vol_RT : 52188

   Ilk :21524

  temper:  60℃

These phenomena are beyond my understanding!But I couldn't replicate it when I debug it.

  • Hi Shang Du,

    How are you detecting these error conditions? How are you reading back the values?

    I can't think of any reason that ADC12 would produce values like you are seeing based on the settings you've shown. Can you confirm that ADC12DF = 0? If not you may be interpreting 2's complement as unsigned binary which could lead to what you are seeing. 

    Also, you haven't should what you are doing with Vol_RT and Ilk. Do you do any post processing? Can you confirm that you aren't writing those variables with bad data? Another possibility is that another part of your program is accidentally writing these memory locations (such as a array out-of-bounds issue).

    Regards,

    Evan

  • Hi, Evan

     I can't confirm that ADC12DF =0.ADC12CTL2 uses the default Settings.(ADC12DF=0)

    Is it possible that the MCU is affected by some kind of lightning strike that causes the ADC12DF to be set for a period of time and then reset to zero.I checked code, Vol_RT isk ilk is in a different memory area. Such as an array out-of-bounds issue was not found.

    As things stand, ADC12DF's guess is more in line with my phenomenon. I will add debugging information to determine whether the case of ADC12DF=1 really occurs, and I will also check the code in detail.

     

  • I think a spurious bit flip is unlikely. 

    To isolate the problem I would strip down your application to the bare minimum (just the analog capture if possible, don't reconfigure analog in the ISR) and see if the problem still occurs. 

    Regards,

    Evan

**Attention** This is a public forum