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.

  • Resolved

CCS/MSP430FR6972: msp430fr6972

Expert 1085 points

Replies: 2

Views: 83

Part Number: MSP430FR6972

Tool/software: Code Composer Studio

Hello,

 I have problem with MSP430FR6972 , in the ADC program..

I am using two ADC( ADC15 & ADC30/integrated temp sensor.)

I take two values, in two different memories (ADC12MEM0 & ADC12MEM1) .

I am getting one value correct that is "ADC12MEM0".

But in case of "ADC12MEM1" ..first time getting correct value.

But if I disconnect the Battery and again connect the Battery.

I am getting wrong value in  "ADC12MEM1".

My ADC function is  :

  

void battery_check(void)
{

       P9SEL1 |= BIT7;   //for A15                       
       P9SEL0 |= BIT7;

                     while(REFCTL0 & REFGENBUSY);            // If ref generator busy, WAIT
                     REFCTL0 |= REFVSEL_0 + REFON;
                     ADC12CTL0 = ADC12SHT0_8 | ADC12ON | ADC12MSC;      // Sampling time, S&H=16, ADC12 on
                     ADC12CTL1 = ADC12SHP | ADC12CONSEQ_1;                   // Use sampling timer
                     ADC12CTL3 = ADC12TCMAP;                                 //A30
                     ADC12CTL2 |= ADC12RES_2;                               // 12-bit conversion results
                     ADC12MCTL0 |= ADC12INCH_15 | ADC12VRSEL_1;
                     ADC12MCTL1 |= ADC12INCH_30 | ADC12VRSEL_1 | ADC12EOS;
                     while(!(REFCTL0 & REFGENRDY));

//                       ADC12IER0 |= ADC12IE1 + ADC12IE0;
                     ADC12CTL0 |= ADC12ENC | ADC12SC;

            BAT_OUTLINE;                     //this line ..can ignore..it is for battery value to display on  LCD purpose
           ADCvar = ADC12MEM0;                     // Read conversion result

            STATUS_METER = STATUS_METER & 0xf0;                    ////this line ..can ignore..it is for battery value to display on  LCD purpose
        if      (ADCvar >= LEVEL_3)  {STATUS_METER |= 0x05; BAT_L1; BAT_L2; BAT_L3; ////this line ..can ignore..it is for battery value to display on  LCD purpose
        }
        else if (ADCvar >= LEVEL_2)  {STATUS_METER |= 0x03; BAT_L1; BAT_L2;  //this line ..can ignore..it is for battery value to display on  LCD purpose
        }
        else if (ADCvar >= LEVEL_1)  {STATUS_METER |= 0x01; BAT_L1;       //this line ..can ignore...it is for battery value to display on  LCD purpose
        }

       if (STATUS_METER & 0x80) SET_LCD_NOT_USE; else CLR_LCD_NOT_USE;    //this line ..can ignore..it is for battery value to display on  LCD purpose
       if (STATUS_METER & 0x10)  SET_LCD_LEAKAGE; else CLR_LCD_LEAKAGE;   //this line ..can ignore...it is for battery value to display on  LCD purpose

//====temp sensor


           temp1 = ADC12MEM1;
           temperatureDegC = (float)(((long)temp1 - CALADC12_12V_30C) * (85 - 30)) /
           (CALADC12_12V_85C - CALADC12_12V_30C) + 30.0f;
           temperatureDegF = temperatureDegC * 9.0f / 5.0f + 32.0f;

           TEMP_METER |= temperatureDegC;

           LCD[0] = digit[(temperatureDegC/100)];     // inbuild sensor  value to display on  LCD 
           LCD[1] = digit[((temperatureDegC%100)/10)]; // inbuild sensor  value to display on  LCD 
           LCD[2] = digit[(temperatureDegC %10)];       // inbuild sensor  value to display on  LCD 

       ADC12CTL0 = 0;
       ADC12CTL0 = ADC12IFGR0;
       ADC12CTL1 = 0;
}



# LCD is OK.
# For "Temp Sensor" : After program download...show actual data....
  But after Battery disconnect and then connect....the Sensor data is not proper.

# I DO NOT WANT TO USE INTERRUPT,

    Can you please help me.

Regards,

Srijit.

  • Hi Srijit,

    I'm wondering you're not even checking the ADC12BUSY bit for completion of the ADC conversion.

    If I see correct, you use the ADC12OSC clock for the ADC.

    Your sampling time is 256 clocks.

    I don't see which clock you use for the CPU.

    Would it make sense to check the busy bit before reading the memory?

    Lukas

  • In reply to Lukas Badura:

    Hello Mr. Lukas,

    Thank you very much for your support.

    It really helped me to solve the problem,

    Regards,

    Srijit

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.