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