Jump to content
Pratik

MSP430FR6989: Constant voltage reference for NTC sensor

Recommended Posts

Hello,

I have MSP430FR6989 Launchpad. As per below schematic,I generate internal Vref+ voltage 1.2V on Pin P1.1. I'm successfully  measure 1.19V on pin P1.1.

So,This Vref I apply in NTC as per below schematic( please ignore MSP430FR4133).   

2260.NTC_5F00_vref.JPG

But I got an issue in below code:

void Vref_ON()

{

while(REFCTL0 & REFGENBUSY);                                     // If ref generator busy, WAIT

REFCTL0 |= REFVSEL_0 + REFON + REFOUT;             // Enable internal 1.2V reference

while(!(REFCTL0 & REFGENRDY));            // Wait for reference generator

                                                                               // to settle

}

void Vref_Off()

{

REFCTL0=1;

}

void setup()

{

Vref_ON();

Serial.begin(9600);

}

void loop()

{

 // int val = analogRead(A11);    //**** When comment this portion then on P1.1 Vref+  get voltage (1.19V), uncomment then get voltage 0V ****

 Serial.println(val);

delay(500);

}

In above code, pin P1.1 I got a 1.19V Vref+ successfully but I got an one issue on above code : Please mention comment in code.

I can't understand above issue.

Please give me a suggestion for issue.

Thank you.

Regards,

Pratik

Share this post


Link to post
Share on other sites

analogRead() will overwrite whatever you have written into REFCTL0 and therefor you are getting 0 as the REFOUT bit is not set. 

To work-around this do the following:

`#define MY_INTERNAL2V0 (ADC12VRSEL_1 | REFON | REFVSEL_0 | REFOUT)`

Then in setup call analogReference(MY_INTERNAL2V0) in setup() and do not call your function Vref_ON().

Share this post


Link to post
Share on other sites

Thanks for your responce.

I'm try `#define MY_INTERNAL2V0 (ADC12VRSEL_1 | REFON | REFVSEL_0 | REFOUT)` but I did not get Vref voltage 1.19V.
 

#define MY_INTERNAL2V0 (REFCTL0|=ADC12VRSEL_1 | REFON | REFVSEL_0 | REFOUT) // without OR with REFCTL0,1.19V not generating

void setup()
{
 analogReference(MY_INTERNAL2V0);
 Serial.begin(9600);
}
void loop()
{
//  // put your main code here, to run repeatedly:
  int val = analogRead(A11);                                         //With this statement again Vref+ getting 0V
//  // float voltage = val * (1.2 / 1023);
//  // Serial.println(voltage*1000);
//  delay(500);
}

Why AnalogRead() function is disturbing with REFCTL0 ?

NOTE: Vref pin P1.1 and ADC pin A11 (MSP430FR6989 Launchpad).

Share this post


Link to post
Share on other sites

You are using Energia API's mixed with setting registers. Energia API's assume exclusive access to registers without user interference.

We can however make this work with one small modification to wiring_analog.c

In wiring_analog.c on line 61 just under the first if defined(__MSP430_HAS_ADC12_B__) change  #define REF_MAP(x)  (x & 0x31) to  #define REF_MAP(x)  (x & 0x33).

You can find the msp430 core in:

  • Linux: ~/.energia15/packages/energia/hardware/
  • Windows: %LOCALAPPDATA%\Energia15\packages\energia\hardware\
  • macOS: ~/Library/Energia15/packages/energia/hardware/

wiring_analog.c is under cores/msp430/

Then use the Sketch below.

#define MY_INTERNAL2V0 (ADC12VRSEL_1 | REFON | REFVSEL_0 | REFOUT)
#define ANALOG_RES 12

void setup()
{
  analogReadResolution(ANALOG_RES);
  analogReference(MY_INTERNAL2V0);
  Serial.begin(115200);
}
void loop()
{
  int val = analogRead(A11);
  /* 
   * Note that the default resolution for the FR6989 is 12 bit. 
   * This can be changed with analogReadResolution(resolution in bits)
   */
  
  float voltage = val * (1.2 / (1 << ANALOG_RES));
  Serial.print(voltage * 1000);
  Serial.println(" mV");
  delay(500);
}

 

Share this post


Link to post
Share on other sites
#define MY_INTERNAL2V0 (ADC12VRSEL_1 | REFON | REFVSEL_0 | REFOUT)

Same issue happen, without RFCTL0 and With analogread() can not get 1.19V on physical pin.

#define MY_INTERNAL2V0 (REFCTL0|=ADC12VRSEL_1 | REFON | REFVSEL_0 | REFOUT) // without OR with REFCTL0,1.19V not generating

I also did modification in wiring_analog.c.  

#define REF_MAP(x)  (x & 0x33). 

Please suggest me alternative of analogread() function using registers of MSP430FR6989.

Thank you in advance.

Share this post


Link to post
Share on other sites
#define MY_INTERNAL2V0 (ADC12VRSEL_1 | REFON | REFVSEL_0 | REFOUT)

Same issue happen, without RFCTL0 and With analogread() can not get 1.19V on physical pin.

#define MY_INTERNAL2V0 (REFCTL0|=ADC12VRSEL_1 | REFON | REFVSEL_0 | REFOUT) // without OR with REFCTL0,1.19V not generating

I also did modification in wiring_analog.c.  

#define REF_MAP(x)  (x & 0x33). 

Please suggest me alternative of analogread() function using registers of MSP430FR6989.

Thank you in advance.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×