[MSP430] Practical ADC use, internal temperature measurement use

Source: Internet
Author: User

First of all talk about the problem, feel this code Compose Studio is rather strange

#include "Tft\tft_driver.h"
File not found, unable to open

No include can use functions only under the same project

Each time you run the program results are different

An example of using an ADC is given below:

ADC Initialization function:

void Configureadctempsensor (void) {/  * Configure ADC Temp Sensor Channel */  ADC10CTL1 = inch_10 + adc10div_0 + CONS eq_2;         Temp Sensor adc10clk/4  adc10ctl0 = sref_1 + adc10sht_3 + MSC + refon + adc10on + adc10ie;//__delay_cycles (1000); c4/>//Wait for ADC Ref to settle  Adc10dtc1=0xfe;  adc10ctl0&=~enc;  while (adc10ctl1&busy);  adc10sa=0x0200; (unsigned int) tempmeasured;  Data buffer start  adc10ctl0 |= ENC + adc10sc;               Sampling and conversion start  __bis_sr_register (Cpuoff + GIE);          LPM0 with interrupts enabled  tempaverage = tempmeasured[0];  Tempcalibrated= Tempaverage;}
For ADC10CTL1 configuration, if you only collect one so that is conseq_2, using internal temperature measurement is inch_10

To know more about the define of the operation register you need to control it in the MSP430G25XX.h and in the User guide

DTC can control the sampling speed to some extent

ADC10SA is the start address, and I use 0x0200 because I know that the start of the data I collect is it,


You need to add these two lines of code in your loop to keep the analog values up to date


    Adc10ctl0 |= ENC + adc10sc;             Sampling and conversion start    __bis_sr_register (Cpuoff + GIE);        LPM0 with interrupts enabled

The second sentence is to let the system into hibernation, reduce power consumption, when our CPU is stopped working, into the interrupt


Interrupt function:

ADC10 Interrupt Service Routine#pragma vector=adc10_vector__interrupt void Adc10_isr (void) {  __bic_sr_register_ On_exit (Cpuoff);        Return to Active mode}
There is only one sentence, it means to end the dormant state, enter the work




[MSP430] Practical ADC use, internal temperature measurement use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.