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.

MSP430FR6989: Use P1.1 as input for External Voltage Reference (VeRef+) on launchpad

Part Number: MSP430FR6989

I am trying to use P1.1 as input for external VeRef. I have removed the S1 on the launchpad and connected the external voltage source of 2048 mV. I set the P1SEL0 and P1SEL1 to BIT1. I also set the ADC12MCTL0 TO ADC12VRSEL_4.

However, I am not able read from P1.1. I am getting a reading of around 2048 from P1.1 even when I ground it. How can I use the P1.1 in the MSP430FR6989 launchpad for VeRef. Should I set REFOUT to 0 and REFON to 0?

Regards

Vijay 

  • Hi Vijay,

    Do you mean you try to use P1.1 as VeRef and want to read the value from P1.1 ADC channel?

    If so, you will always get a full-scale result since ADC is comparing the input voltage with the reference, i.e. the conversion range is up to the reference voltage.

    If you want to validate the VeREF, you can inject another fixed voltage (need to be lower than the reference voltage you used in P1.1) from other ADC input channel and to see the conversion result.

    Regards,

    Harry

  • Harry

    I am not trying to use the P1.1 as ADC channel. I have connected the Vref from REF3320AIDBZT on my sensor board which gives a constant 2048mV to the P1.1 and I am trying to see if I am getting the correct value on my VeRef (P1.1). Below is the output of pins P1.1, P8.4 and P8.5. I have connected VeRef 2048mV to P1.1 and P8.4 and I have connected CO sensor output to P8.5.

    Ouput with no connections to P1.1, P8.4 and P8.5

    VeRef: 2046 A7 Value: 814 A6 Value: 609
    VeRef: 2046 A7 Value: 670 A6 Value: 593
    VeRef: 2046 A7 Value: 1532 A6 Value: 687
    VeRef: 2046 A7 Value: 537 A6 Value: 570
    VeRef: 2046 A7 Value: 939 A6 Value: 621
    VeRef: 2046 A7 Value: 1397 A6 Value: 675
    VeRef: 2046 A7 Value: 398 A6 Value: 554

    Output with VeRef to P1.1, P8.4 and CO sensor to P8.5

    VeRef: 2046 A7 Value: 2535 A6 Value: 519
    VeRef: 2046 A7 Value: 2539 A6 Value: 616
    VeRef: 2046 A7 Value: 2537 A6 Value: 688
    VeRef: 2046 A7 Value: 2539 A6 Value: 500
    VeRef: 2047 A7 Value: 2541 A6 Value: 664
    VeRef: 2046 A7 Value: 2539 A6 Value: 649
    VeRef: 2042 A7 Value: 2541 A6 Value: 510

    Output with VRef to P1.1, Battery 1.5V to P8.4 and CO sensor to P8.5

    VeRef: 2047 A7 Value: 1965 A6 Value: 527
    VeRef: 2052 A7 Value: 1964 A6 Value: 679
    VeRef: 2046 A7 Value: 1965 A6 Value: 558
    VeRef: 2046 A7 Value: 1966 A6 Value: 535
    VeRef: 2054 A7 Value: 1966 A6 Value: 671
    VeRef: 2047 A7 Value: 1974 A6 Value: 525

    Output with Battery 1.5V to P1.1, P8.4 and CO sensor to P8.5

    VeRef: 2046 A7 Value: 1944 A6 Value: 544
    VeRef: 2048 A7 Value: 1941 A6 Value: 598
    VeRef: 2041 A7 Value: 1941 A6 Value: 590
    VeRef: 2046 A7 Value: 1940 A6 Value: 560
    VeRef: 2039 A7 Value: 1938 A6 Value: 623

    Output with P1.1 and P8.4 to GND

    VeRef: 2046 A7 Value: 0 A6 Value: 574
    VeRef: 2046 A7 Value: 2 A6 Value: 462
    VeRef: 2046 A7 Value: 0 A6 Value: 437
    VeRef: 2046 A7 Value: 0 A6 Value: 535
    VeRef: 2046 A7 Value: 0 A6 Value: 615
    VeRef: 2049 A7 Value: 5 A6 Value: 552
    VeRef: 2046 A7 Value: 0 A6 Value: 442

    My questions are:

    1. If the full scale resolution of 12bit ADC is 4096, why am I always reading around 2046 on VeRef? Even when it is not connected.

    2. Why are values on the P8.4 not the same as P1.1 when both are connected to the same voltage?

    3. Even when I connect the CO sensor pin to P1.1, the values are still showing 2046. It is the same with Battery of 1.5V

    4. If I connect to both the VeRef and the ADCs to the same constant voltage source should I not get the same readings?

    5. How can I calibrate P1.1 to 2048mV? What are calculation should use to get corrected reading on P8.4 and P8.5?

    6.  What is the calculation to get the 2048mV on P8.4 when it is also connected to VeRef?

    Thank you for your patience in advance.

    Regards

    Vijay

  • Hi Vijay,

    I noticed you mentioned you are using REFOUT = 1. Could you please take a quick try to set it to 0?

    When setting REFON and REFOUT to 1, P1.1 will output the internal reference out, and may have conflict if you connect some external voltage to it at the same time.

    Meanwhile, according to your test data, I noticed that when you connect the 2.048V to P8.4, the result is around 2540, which indicates that the reference is around 3.3V (2.048/2540*4096 = 3.3V). Could you please also double check the ADC12VRSEL bits to see if it works as expected?

    Also, I'm curious about how you get P1.1 result? Do you also read P1.1 from ADC channel A1? 

    There are something wired in the P1.1 result, which I'm now have little clue with it.

    Look forward to your update and also will let you know if I got something new.

    Regards,

    Harry

  • Harry

    I have removed the switch from the launchpad and connected the P1.1 to the VeRef. There is nothing else wired to it. I am reading from the P1.1 just like I am reading from the P8.4 and P8.5. Is this wrong?

    As per the design reference, the setting for VeRef and ADC is the same. So I assumed that P1.1 will act as ADC input for VeRef.

    Below is the partial code

    // REFCTL0 &= 0x00;

    P8SEL1 |= 0x0F;
    P8SEL0 |= 0x0F;

    P1SEL1 |= 0x03;
    P1SEL0 |= 0x03;
    ADC12MCTL0 = ADC12VRSEL_4;

    With VeRef connected P1.1 and P8.4 the out is

    VeRef: 2047 A7 Value: 2529 A6 Value: 579
    VeRef: 2047 A7 Value: 2539 A6 Value: 563
    VeRef: 2039 A7 Value: 2533 A6 Value: 666
    VeRef: 2046 A7 Value: 2540 A6 Value: 647

    The yellow and orange wires are connected to VRef of the sensor board. I checked the VRef of sensor board with multi meter and it is exactly 2048 mV.

  • Hi Vijay,

    Could you please try to set REFOUT = 0?

    What I want to say is that you should not use P1.1 as reference and also read its "ADC conversion result" from A1. ADC uses reference to convert thus if you read out the reference value it should reach to full range (4095 here for 12-bit). But as you mentioned you have turned on REFOUT, the internal reference will also output from P1.1 (VRef+ function). So I suspect that there may be some conflict if you also put an external voltage at the same pin.

  • I have set the REFOUT=0. Even in my earlier code I have not set REFOUT to 1.

    REFCTL0 &= 0x00;

    P8SEL1 |= 0x0F;

    P8SEL0 |= 0x0F;

    P1SEL1 |= BIT1;
    P1SEL0 |= BIT1;

    ADC12CTL2 |= ADC12RES__12BIT;
    ADC12MCTL0 |= ADC12VRSEL_4;

    Below is the output with VeRef connected to P1.1, P8.4 and CO sensor to P8.5. I see no change. How can I know for sure that VeRef  is working without reading from it? Is there any workaround for this? I want to make sure that I get the same value on both P1.1 and P8.4 when I connect the external voltage source.

    Regards

    Vijay

  • Hi Vijay,

    Just realized the issue. You use P1.1 (A1), P8.4(A7) & P8.5(A6) right? Then you 'd better use three different ADC channels, i.e. three different ADC12MCTLx/ADC12MEMx register group.

    An example is as below:

        ADC12MCTL0 |= ADC12VRSEL_4 | ADC12INCH_1;     // P1.1/A1 in ADC12MCTL0/ADC12MEM0
        ADC12MCTL1 |= ADC12VRSEL_4 | ADC12INCH_7;     // P8.4/A7 in ADC12MCTL1/ADC12MEM1
        ADC12MCTL2 |= ADC12VRSEL_4 | ADC12INCH_6;     // P8.5/A6 in ADC12MCTL2/ADC12MEM2

    Also, you need to read the result in different ADC12MEMx.

    In your previous setting, the result of P8.4 shows that in conversion the reference still uses AVCC 3.3V (the default setting).

    In this case you would expect to see ADCMEM0 and ADCMEM1 at full range since you use VeREF+ as reference and also read the same signal in the ADC channel.

    For your previous P1.1 result of around 2046, I guess it's actually P1.0 result since you didn't set the ADC12INCHx bits and in the LaunchPad P1.0 is connected with resistor and LED.

    Could you please take a try with my code configuration here?

    Regards,

    Harry

  • Thank you. I got the readings below

    VeRef: 4095
    A7: 4094
    A6: 2010
    A5: 1998
    A4: 1999

**Attention** This is a public forum