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.

Basic ADC question

Other Parts Discussed in Thread: MSP430F2274, CC2500, SIMPLICITI

Greetings,

I am trying to print (in hyperterminal) the binary value that is stored in the ADC10MEM register after I take a sample. Can you fellows provide some guidance or sample code?

Thank you very much.

  • kpbr said:

    I am trying to print (in hyperterminal) the binary value that is stored in the ADC10MEM register after I take a sample. Can you fellows provide some guidance or sample code?

    You will need to take the 10-bit binary value read from the ADC10 and convert this into 3 ASCII characters to be viewed by Hyperterminal.  For instance, if you want to see the value "0x3FF" on the Hyperterminal screen, the following characters need to be sent by the target device over the UART interface:
    030h 078h 033h 046h 046h

    You can get a copy of the ASCII character table at http://www.asciitable.com/

    0 : 0x30 or 030h
    x : 0x78 or 078h
    3 : 0x33 or 033h
    F : 0x46 or 046h
    F : 0x46 or 046h

    If you don't care about seeing the prepending 0x, then you can simply not transmit the first 030h 078h characters.

    You will need to create a conversion routine to take the 10-bit value and convert it into 2 8-bit hex values.  The upper 2 bits of the 10-bit value will have values between 0 and 3.  These are represented by 0x30 through 0x33 hex values.  Therefore, you can simply add the upper 2 bits to 0x30 to get the first character transmitted.
    The lower 8 bits of the 10-bit value need to be split into nibbles, or 4-bit values that can then be represented by 0 through 9 or A through F.  If the nibble is > 10, then subtract 10 and add this value to 0x41 (an ASCII A character).  If the nibble is < 10, then add this value to 0x30 (an ASCII 0 character).

    Something like the below is what I was thinking.

     

    char AsciiValue[3] ;

    AsciiValue[0] = ((ADC10MEM >> 8) & 0x03) + 0x30 ;

    if (((ADC10MEM >> 4) & 0x0F) > 10)
    {
      AsciiValue[1] = (((ADC10MEM >> 4) & 0x0F) - 10) + 0x41 ;
    }
    else
    {
      AsciiValue[1] = ((ADC10MEM >> 4) & 0x0F) + 0x30 ;
    }

    if ((ADC10MEM & 0x0F) > 10)
    {
      AsciiValue[2] = ((ADC10MEM & 0x0F) - 10) + 0x41 ;
    }
    else
    {
      AsciiValue[2] = (ADC10MEM & 0x0F) + 0x30 ;
    }

     

     

     

  • Thank you for the code/advice.

    I was also hoping to find out how to convert the ADC10MEM register to a voltage. I've examined the sample code that is provided by TI, but I am not fully understanding the equation that is being used. I think it may be due to the built in reference voltages provided on the MCU (1.5V and 2.5V). Can anyone provide some insight on how to accurately convert?

    Thanks again.

  • kpbr said:

    I was also hoping to find out how to convert the ADC10MEM register to a voltage. I've examined the sample code that is provided by TI, but I am not fully understanding the equation that is being used. I think it may be due to the built in reference voltages provided on the MCU (1.5V and 2.5V). Can anyone provide some insight on how to accurately convert?

    The document you need to reference is the MSP430x1xx Family User's Guide (SLAU049) or the MSP430x2xx Family User's Guide (SLAU144) and look at the ADC10 section.  The value of ADC10MEM will be the output of the following equation mentioned in the aforementioned user's guides when performing a straight conversion (ie. not 2's complement).

    Nadc = 1023 x (Vin - Vref-)/(Vref+ - Vref-)

    Since the ADC10 is a 10-bit A/D converter, the range of values will be 0x000 to 0x3FF.  These range of values will be related to the Reference Voltage.  The reference voltage can be either the internal reference which can be configured as 1.5V or 2.5V, or Vcc the supply rail to the device, or an external reference.

     

    For example, let's choose our Vref+ = 2.5V and Vref- = GND (or 0V).  Keep in mind, if Vin is above Vref+, the output of the ADC will be clamped at 0x3FF, so you need to make sure your input voltage that you are measuring is within Vref- < Vin < Vref+.

    If you read Nadc=0x100, then Vin would be :

    Vin = Nadc/1023 * Vref
           = 256/1023 * 2.5V
           = 0.625V

  • Thank you very much for you help.

    This did raise another question however. If you set your reference voltages to be AVcc and AVss for Vref+ and Vref-, respectively, what if you have a changing power supply. For example, a battery powered application.

    Also, I am noticing in the eZ430-RF2500 Demo Software, supplied by TI, has some interesting settings. The ADC is configured as follows:

    ADC10CTL0 = SREF_1 + ADC10SHT_2 + REFON + ADC10ON + ADC10IE + REF2_5V;

    This is code from the Access Point software where the ADC is used to measure supply power (which is off the USB from the computer).

    I am confused as to what SREF_1 is doing. It appears as if they have decided to use the internal voltage reference, set to 2.5V. But SREF_1, according to the msp430x22x4.h header file sets VR+ = VREF+ and VR- = AVss. My confusion lies with not understanding what bits 13 through 15 do on the ADC10CTL0 register.

    Another artifact that I notice is that the equations used in the sample software is capable of producing 3.5V (from the USB). Since the voltage reference only goes to 2.5V, I assume they are using an altered equation.

    Thank you very much.

     

  • kpbr said:

    If you set your reference voltages to be AVcc and AVss for Vref+ and Vref-, respectively, what if you have a changing power supply. For example, a battery powered application.

    I don't believe you would get results that are meaningful, if your reference moves around.  If you have such a scenario, I would suggest generating a reference voltage that is a known value through the entire input Vcc swing that the MSP430 device would be subjected to.

     

    kpbr said:

    Also, I am noticing in the eZ430-RF2500 Demo Software, supplied by TI, has some interesting settings. The ADC is configured as follows:

    ADC10CTL0 = SREF_1 + ADC10SHT_2 + REFON + ADC10ON + ADC10IE + REF2_5V;

    This is code from the Access Point software where the ADC is used to measure supply power (which is off the USB from the computer).

    I would suggest reviewing the eZ430-RF2500 schematics from the eZ430-RF2500 Development Tool Users Guide (SLAU227) in addition to the MSP430x2xx Family User's Guide (SLAU144) in the ADC10 section.  Figure 20-1 of (SLAU144) illustrates the structure of the ADC10 of the MSP430x2xx device.  The Wireless Sensor demo application for the eZ430-RF2500 in SLAC139 configures the ADC10 channel input to A11 via the following line just before the line cited above.

          ADC10CTL1 = INCH_11;                    // AVcc/2
          ADC10CTL0 = SREF_1 + ADC10SHT_2 + REFON + ADC10ON + ADC10IE + REF2_5V;

    This configures the ADC10 to convert the channel 11 input to the ADC10, which is the AVcc/2 via the circuit in the lower left-hand corner of Figure 20-1 of SLAU144, which is a resistor divider of AVcc.

    On the schematics of the eZ430-RF2500, AVcc is connected to VCC_EXT on the RF Target board (ie. MSP430F2274+CC2500), which is provided by VCC of the MSP-eZ430U board which is +3.6V maximum.  Therefore, AVdd/2 would be 3.6V/2 or 1.8V.

     

    kpbr said:

    I am confused as to what SREF_1 is doing. It appears as if they have decided to use the internal voltage reference, set to 2.5V. But SREF_1, according to the msp430x22x4.h header file sets VR+ = VREF+ and VR- = AVss. My confusion lies with not understanding what bits 13 through 15 do on the ADC10CTL0 register.

    Bits 15:13 of ADC10CTL0 select what is connected to the VR+ and VR- of the ADC10 to determine the reference voltage.  These bits correspond to SSEL[2:0].  Again, I would suggest referencing Figure 20-1 of SLAU144 to reconcile the SSEL[2:0] to configuration functionality of the ADC10.  SSEL[2] (bit 15 of ADC10CTL0) configures what is connected to VR-, either Vss or VeREF-.  SSEL[1:0] (bit 14:13 of ADC10CTL0) configures what is connected to VR+ of the ADC10, either buffered VeREF+, unbuffered VeREF+, buffered Vref=1.5V or Vref=2.5V, or AVcc.

     

    kpbr said:

    Another artifact that I notice is that the equations used in the sample software is capable of producing 3.5V (from the USB). Since the voltage reference only goes to 2.5V, I assume they are using an altered equation.

    What equation is it you are referencing?

  • BrandonAzbell said:
    I don't believe you would get results that are meaningful, if your reference moves around.  If you have such a scenario, I would suggest generating a reference voltage that is a known value through the entire input Vcc swing that the MSP430 device would be subjected to.

    If I knew my input voltage is going to be between 0.5V and 1.5V, would the internal 2.5V reference be a suitable choice?

    BrandonAzbell said:

    I would suggest reviewing the eZ430-RF2500 schematics from the eZ430-RF2500 Development Tool Users Guide (SLAU227) in addition to the MSP430x2xx Family User's Guide (SLAU144) in the ADC10 section.  Figure 20-1 of (SLAU144) illustrates the structure of the ADC10 of the MSP430x2xx device.  The Wireless Sensor demo application for the eZ430-RF2500 in SLAC139 configures the ADC10 channel input to A11 via the following line just before the line cited above.

          ADC10CTL1 = INCH_11;                    // AVcc/2
          ADC10CTL0 = SREF_1 + ADC10SHT_2 + REFON + ADC10ON + ADC10IE + REF2_5V;

    This configures the ADC10 to convert the channel 11 input to the ADC10, which is the AVcc/2 via the circuit in the lower left-hand corner of Figure 20-1 of SLAU144, which is a resistor divider of AVcc.

    On the schematics of the eZ430-RF2500, AVcc is connected to VCC_EXT on the RF Target board (ie. MSP430F2274+CC2500), which is provided by VCC of the MSP-eZ430U board which is +3.6V maximum.  Therefore, AVdd/2 would be 3.6V/2 or 1.8V.

    For clarification, the ADC10 is configured to use the 2.5V reference, and they are sampling a voltage divider off the power supply. Therefore, they would need to multiply the sampled value by 2 in order to convert to the correct voltage.

    BrandonAzbell said:

    Bits 15:13 of ADC10CTL0 select what is connected to the VR+ and VR- of the ADC10 to determine the reference voltage.  These bits correspond to SSEL[2:0].  Again, I would suggest referencing Figure 20-1 of SLAU144 to reconcile the SSEL[2:0] to configuration functionality of the ADC10.  SSEL[2] (bit 15 of ADC10CTL0) configures what is connected to VR-, either Vss or VeREF-.  SSEL[1:0] (bit 14:13 of ADC10CTL0) configures what is connected to VR+ of the ADC10, either buffered VeREF+, unbuffered VeREF+, buffered Vref=1.5V or Vref=2.5V, or AVcc.

    When the SREF_1 is used (VR+ = VREF+ and VR- = AVSS), this is configuring the ADC10 to use the reference voltage (in this case, since REF2_5V is set, it is the 2.5V reference). But if I were to, for example, use SREF_0 (VR+ = AVCC and VR- = AVSS), this would use the power supply for VR+ and GND for VR-.

    I will re-read the manual on this section, but I am still somewhat confused by how these bits are suppose be used. It seems that if you were to configure the ADC10 to have REFON + REF2_5V you would have configured it correctly for have a 2.5V reference-generated VR+ and GND for VR-.

    Would there be an issue if you set REFON + REF2_5V, but then set SREF_0 (VR+ = AVCC and VR- = AVSS)? If I am now understanding correctly, this would attempt to configure the ADC10 with an internally generated voltage reference of VR+ = 2.5V and VR- = GND, as well as, because of SREF_0 being set VR+ = AVcc.

    BrandonAzbell said:
    What equation is it you are referencing?

     I was confused that it appeared as if the voltage reference was set to 2.5V, yet I am seeing 3.5V on HyperTerminal. After looking at Figure 20-1 in the manual, I am seeing that INCH_11 is sampling AVcc/2, which will always stay within the bounds of Vref- < Vin < Vref+ when using the internal 2.5V reference.

    Thank you for all your help. Your detailed responses are much appreciated. This forum is a great source of information and help.

    However, I am still struggling with getting ADC to work correctly, but soon I will get there. I appreciate all the help given thus far.

  • kpbr said:

    If I knew my input voltage is going to be between 0.5V and 1.5V, would the internal 2.5V reference be a suitable choice?

    I would say yes, but it really depends on what you need to measure.  Keep in mind the power supply to the MSP430F2274 requires Vcc >= 2.2V for a 1.5V internal reference and Vcc >= 3V for a 2.5V internal reference.  This comes from the MSP430F2274 datasheet.
    Secondly, you should also review the accuracy of the internal reference generator, as it is accurate to +-2LSBs.  If you need more precision, the use of an external voltage reference should be used via VeREF+.  There are many low power, higher precision voltage references available.
    Examples are the REF32xx and REF33xx devices.

     

    kpbr said:

    For clarification, the ADC10 is configured to use the 2.5V reference, and they are sampling a voltage divider off the power supply. Therefore, they would need to multiply the sampled value by 2 in order to convert to the correct voltage.

    I believe there is an implicit multiply by 2 factor in the following equation from the demo_AP.c file.

          temp = results[1];
          volt = (temp*25)/512;

    The usual equation would be volt = (temp * 25) / 1024.

     

    kpbr said:

    When the SREF_1 is used (VR+ = VREF+ and VR- = AVSS), this is configuring the ADC10 to use the reference voltage (in this case, since REF2_5V is set, it is the 2.5V reference).

    Agreed.

     

    kpbr said:

    But if I were to, for example, use SREF_0 (VR+ = AVCC and VR- = AVSS), this would use the power supply for VR+ and GND for VR-.

    Agreed.

     

    kpbr said:

    I will re-read the manual on this section, but I am still somewhat confused by how these bits are suppose be used. It seems that if you were to configure the ADC10 to have REFON + REF2_5V you would have configured it correctly for have a 2.5V reference-generated VR+ and GND for VR-.

    I disagree.  Setting REFON + REF2_5V has the effect of turning on the internal reference voltage generator and configuring it for an output of 2.5V.  That's it.  It does not connect the output of the internal reference voltage generator to VR+ or GND to VR-.  Connecting the output of the internal reference voltage generator to VR+ is done via SREF[1:0] and connecting GND to VR- is done via SREF[2].

     

    kpbr said:

    Would there be an issue if you set REFON + REF2_5V, but then set SREF_0 (VR+ = AVCC and VR- = AVSS)? If I am now understanding correctly, this would attempt to configure the ADC10 with an internally generated voltage reference of VR+ = 2.5V and VR- = GND, as well as, because of SREF_0 being set VR+ = AVcc.

    No issue other than burning additional power which is not needed.  It is one thing to configure the internal reference voltage generator to be on and set to a voltage.  But you further need to connect it to the ADC10, which is done by other configuration bits, ie. SREF[2:0].

  • I have now gotten the ADC convert values correctly, thanks for all your help and guidance. I do have one last question, however. How can I print a value with more resolution? For example, once it has executed the following statements

    temp = results[1];
    volt = (temp*25)/512;

    when connected via USB, volt would be roughly 35. Following this, before, the voltage is displayed on hyperterminal, volt%10 is used to pull out the 5, and (volt/10)%10 is used to pull out the 3. Do you have any hints on how I could use this to get resolution to the 100ths or 1000th place?

    Thanks again!

  • kpbr said:

    How can I print a value with more resolution?

    With a 2.5V reference and using the equation volt = (ADC10MEM * 2.5V)/1024, each bit of the 10-bit value represents 0.00244V, or ~2.44mV.

    My suggestion would be to use the following to get more bits of resolution.

    temp = results[1] ;
    volt = (temp * 2500)/512 ;

    This will allow you to display down to 1000th place and still remain with the dynamic range of a 16-bit number.

     

     

  • I am also trying to show more resolution for the voltage value.  I tried the suggested code, but could not get the correct voltage when I convert it to be displayed in hyperterminal.

    temp = results[1] ;
    volt = (temp * 2500)/512 ;

    I added code to the function below to display the 100ths and 1000ths place in hyperterminal.

    void transmitDataString(char addr[4],char rssi[3], char msg[MESSAGE_LENGTH] )

        output_verbose[32] = '0'+((msg[2]/1000)%10);
        output_verbose[34] = '0'+((msg[2]/100)%10);
        output_verbose[35] = '0'+((msg[2]/10)%10);
        output_verbose[36] = '0'+(msg[2]%10);

    Here is the message line I am sending....

    char output_verbose[] = {"\r\nNode:XXXX,Temp:-XX.XC,Battery:X.XXV,Sensor:X.XV,Strength:XXX%,RE:no "};        //(Sensor voltage is an external voltage I am measuring)

    The voltage being read is the HUB voltage (3.5V).  Instead of displaying 3.5?? V, I am now getting 0.004V (and also 0.009V and 0.014V) on hyperterminal for the HUB voltage.

    This seems so simple.  Please advice what I am doing wrong.

    Thanks!

     

     

  • CynthiaWatkins said:
        output_verbose[32] = '0'+((msg[2]/1000)%10);
        output_verbose[34] = '0'+((msg[2]/100)%10);
        output_verbose[35] = '0'+((msg[2]/10)%10);
        output_verbose[36] = '0'+(msg[2]%10);

    Your math checks out with how I would do it. I have yet to implement this on my MCU, but I will try tonight and update with my results.

    If you want to read 3.5??V, make sure you update your output_verbose array to have the battery be Battery:X.XXXV. You are currently missing a "placeholder" for your thousandth position.


    KPBR

  • I was able to try out the equation and I have confirmed that it works. However, it doesn't have the resolution I expected. The 10ths place digit is off by 1/10V to 2/10V when comparing to what my Fluke hand meter reads.

    Here is the code that I used:

    int degC;
      volatile long sample;
      int voltage;
     
      char DisplayString[] = {"\r\nX.XXX"};
      
      
      ADC10CTL0 = SREF_1 + ADC10SHT_2 + REFON + ADC10ON + ADC10IE + REF2_5V;
      for( degC = 240; degC > 0; degC-- );
      ADC10CTL0 |= ENC + ADC10SC;
      __bis_SR_register(CPUOFF + GIE);
      sample = ADC10MEM;
      ADC10CTL0 &= ~ENC;
      
      voltage = (sample * 2500)/1023;
      DisplayString[2] = '0'+(voltage/1000)%10;
      DisplayString[4] = '0'+(voltage/100)%10;
      DisplayString[5] = '0'+(voltage/10)%10;
      DisplayString[6] = '0'+(voltage%10);
     
      TXString(DisplayString, sizeof DisplayString);

    Timer_A runs this code every second.

  • Thanks for replying! 

    My problem was with the fact that the orginal demo code stores the voltage in a char variable.  I changed it to int for the demo_AP.c code and it worked....I was able to display more resolution.  But, I don't think I can do this as easily (maybe not even at all) for the end point device (using demo_EP.c), because the voltage is sent as uint8_t type.  I looked and it appears that all the wireless transmission functions have this uint8_t type in the functions.  

    Do you know if this is easily changeable?

    Thanks!  

  • CynthiaWatkins said:

    My problem was with the fact that the orginal demo code stores the voltage in a char variable.  I changed it to int for the demo_AP.c code and it worked....I was able to display more resolution.  But, I don't think I can do this as easily (maybe not even at all) for the end point device (using demo_EP.c), because the voltage is sent as uint8_t type.  I looked and it appears that all the wireless transmission functions have this uint8_t type in the functions.  

    Do you know if this is easily changeable?

    Which code base are you referencing?

  • We have the eZ430-RF2500 demo kit that uses the MSP430F2274 microcontroller. 

    By looking at the #include files that are in the demo_EP.c code that came with the demo kit, it looks like the wireless transmission was set-up to transmit an 8 bit number.   

  • Yes, the underlining message structure is implemented in bytes, but a SimpliciTI message can be up to 52 bytes in size.

  • kpbr said:

    I was able to try out the equation and I have confirmed that it works. However, it doesn't have the resolution I expected. The 10ths place digit is off by 1/10V to 2/10V when comparing to what my Fluke hand meter reads.

    Here is the code that I used:

    int degC;
      volatile long sample;
      int voltage;
     
      char DisplayString[] = {"\r\nX.XXX"};
      
      
      ADC10CTL0 = SREF_1 + ADC10SHT_2 + REFON + ADC10ON + ADC10IE + REF2_5V;
      for( degC = 240; degC > 0; degC-- );
      ADC10CTL0 |= ENC + ADC10SC;
      __bis_SR_register(CPUOFF + GIE);
      sample = ADC10MEM;
      ADC10CTL0 &= ~ENC;
      
      voltage = (sample * 2500)/1023;
      DisplayString[2] = '0'+(voltage/1000)%10;
      DisplayString[4] = '0'+(voltage/100)%10;
      DisplayString[5] = '0'+(voltage/10)%10;
      DisplayString[6] = '0'+(voltage%10);
     
      TXString(DisplayString, sizeof DisplayString);

    Timer_A runs this code every second.

     

    I find this code extremely helpful. Is this the only change needed from the demo code? If not, could you post the entire code file?

    Any help is greatly appreciated.

     

  • This did not come from the demo code (but I did pull some of the code from the demo software). I wrote a program to simply test the ADC module on the MSP430.

    I configured Timer_A (as they do in the demo code) to run the above code every second. Then I have an infinite while loop which does nothing, so Timer_A runs the show.

    I can post the entire code set this evening.

     

  • I have basic problem with ADC part of ez2500, instade making new topic, I would like to ask here.

    I'd like to seample input voltage on pin P2.1 on my ez2500 (MSP2274), but I can't. Here is code example:

    #include "msp430x22x4.h"

    void main(void)
    {
     
      WDTCTL = WDTPW + WDTHOLD; // Stop WDT
      ADC10CTL0 = ADC10SHT_2 + ADC10ON; // ADC ON
      ADC10AE0 |= 0x02; // P2.1 ADC A0
      P1DIR |= 0x03;  
      P1OUT &= 0xFC;  
     
      while(1)
      {
      ADC10CTL0 |= ENC + ADC10SC; // Start seampling
      if (ADC10MEM < 512)P1OUT |= 0x01; // Red Led on if ADC < Half Vcc
      else P1OUT &= 0xFC;
      }
    }

    If I change upper program with 'ADC10AE0 |= 0x01;' and seample on P2.0, everything work fine. Has anybody know what I'm doing wrong? Hardware problem?

     

    Thnx for answers!

  • I would suggest taking a look at the code examples for the MSP430F22x4 (SLAC123) available on the MSP430F2274 Product Folder.  It appears the sample code you provided is fairly close to the msp430x22x4_adc10_01.c example.
    However, you don't have a check for ADC10CTL0.ADC10IFG flag being set before accessing the ADC10MEM register.  You should wait for the ADC10IFG to be set to communicate when the conversion has completed.  Please see the Single-Channel, Single-Conversion Mode flow diagram on page 20-10 of the MSP430x2xx Family User's Guide (SLAU144).  At the end of the conversion, the ADC10IFG flag is set in the ADC10CTL0 register.

    The other thing to consider is that not all Port pins are constructed the same in terms of multiplexing options.  Please refer to the MSP430F2274 datasheet to see a schematic for the P2.1 pin versus the P2.0 pin.

  • Thnx for quick answer. I check all things you said, but I still don't get it. Maybe I wasn't clear before.

    If I seample on Pin2.0, seampling works fine, seample value is just what I expected it. If I want to seample on any other pin like Pin2.1 or 2.2...I always get random seample value . With this instruction ADC10AE0 |= 0x0X; (X = 1, 2, 3...), selecting seampling pin.

    If there is logical connection, seampling must work, no mather whitch adc port, from (A0 - A8), I choose?! Because it is alredy working on A0. Right?

  • Sorry for the delay in the response.

    We actually need to hit two registers in order to enable a single sample conversion.  The example code you were using only enables the pin P2.0, or P2.1, etc. to be enabled as an analog input, but this does not communicate to the ADC10 which channel to sample.
    That is controlled in ADC10CTL1.INCHx bitfield.  This particular bitfield defaults to 0, therefore always selecting A0 as the channel to sample, regardless if it is enabled by ADC10AE0.1.

    The modified code is below:

    #include "msp430x22x4.h"

    void main(void)
    {
     
      WDTCTL = WDTPW + WDTHOLD; // Stop WDT
      ADC10CTL0 = ADC10SHT_2 + ADC10ON; // ADC ON
      ADC10CTL1 = 0x1000; // Select single sample-conversion for ADC Ch1
      ADC10AE0 = 0x02; // P2.1 ADC A1
      P1DIR |= 0x03;  
      P1OUT &= 0xFC;  
     
      while(1)
      {
      ADC10CTL0 |= ENC + ADC10SC; // Start seampling
      if (ADC10MEM < 512)P1OUT |= 0x01; // Red Led on if ADC < Half Vcc
      else P1OUT &= 0xFC;
      }
    }

  • I decided to study ADC in deeper detail and  I found how to seample on other pins. It is just like you say.
    But I forgot to write down the solution in this topic.[:$]

    Thnx for answer anyway.

     

  • Hi,

    To obtain better resolution and better precision of volt, I tried to do this :

    long volt;  // instide to int
    float volt1=((float)temp*2500)/512;
    volt=(long) volt1; 

    But I would like to obtain better precision , can any one give me better solution?

**Attention** This is a public forum