用MSP430G2553 adc10内置的温度传感器采集温度 5秒钟采集一次 用delay(5000); 在loop();里只发送一次数据 就没下文了
int temp=0;
void adcinit(void)
{
WDTCTL = WDTPW | WDTHOLD;
ADC10CTL1 |= CONSEQ_2;
ADC10CTL0 |= SREF_1+REFON;
ADC10CTL0 |= ADC10SHT_3+MSC;
ADC10CTL1 |= ADC10SSEL_3+SHS_0;
ADC10CTL1 |= INCH_10;
ADC10CTL0 |= ADC10ON;
}
int adcdata(void)
{
ADC10CTL0 |= ENC + ADC10SC;
while((ADC10CTL0 & ADC10IFG)==0)
temp =(((int)ADC10MEM-728)/(0.000355*678)+219)/10;
}
void setup()
{
Serial.begin(9600);
adcinit();
}
void loop()
{
adcdata();
Serial.print("temp: ");
Serial.println(temp);
delay(5000);
}
此帖出自
小平头技术问答
没折腾过
一周热门 更多>