MSP430 uses ADC10 to measure the voltage of the temperature diode inside the chip

Publisher:陈风102Latest update time:2018-01-30 Source: eefocusKeywords:msp430  ADC10 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

MSP430 uses ADC10 to measure the voltage of the temperature diode inside the chip
#include "msp430x22x4.h" 
//This program uses ADC10 to measure the voltage of the temperature diode inside the chip 
//Execute the program to view the value of the ADC10MEM register, 
//and use the formula V(temp)=0.00355*TempC+0.986 to calculate the chip temperature 
//Finally, the ad sampling value is stored in ad_value, and the temperature value is stored in value. Set breakpoints to view each count value

// MSP430F2274 
// ----------------- 
// /|\| XIN|-   
// | | | 
// --|RST XOUT|- 
// | | 
/ / | P1.0|-->LED 
float ad_value; 
float value; 
int a[]={0xc0,0xf9,0xa4,0xb0,0x99,0xa92,0x82,0xf8,0x80,0x90};/*Common Yang*/ 
/ /int a[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};/*Common Yin*/ 
int p1,p2,p3,p4; 
int m,i; 
void delay () 

  for(i=0;i<=100;i++); 

int main( void ) 
{   
  WDTCTL=WDTPW+WDTHOLD; //Turn off the watchdog 
  BCSCTL1 =CALBC1_1M Hz ; //Set DCO to 1MHZ 
  DCOCTL =CALBC1_1MHZ; 

  P3SEL=0x00; 
  P3DIR=0xff; 
  P3OUT=BIT0+BIT1+BIT2+BIT3; 

  P4SEL=0x00; 
  P4DIR=0xff; 
  P4OUT=0x00; 

  TACTL|=TASSEL0; 
  TACTL|= TACLR;                     
  CC TL0 |=CCIE;                           
  CCR0 =32768;  

  ADC10CTL1=INCH_10; //Select channel 10, which is the internal temperature sensor 
  ADC10CTL0=REFON+SREF_1; //Turn on 1.5V positive reference, ground as negative reference 
  ADC10CTL0 |=ADC10ON+ADC10SHT_3+ADC10IE; //Open the ADC10 core, set the sampling and holding time to 64 ADC10CLK, enable ADC10 interrupt 
  ADC10CTL0 |=ENC+ADC10SC; //Start AD conversion_BIS_SR 
  (GIE+CPUOFF); //Open the general interrupt and enter the low power 
  value =((ad_value*1.5/1023)-0.986)/0.00355; //Calculate temperature 

  p1=(int)value/10; 
  p2=(int)value%10; 
  m=(int)(value*100)%100; 
  p3=m/10; 
  p4=m%10; 
  while(1) 
  { 
   P3OUT=BIT3; 
   P4OUT=a[p1]; 
   delay(); 
   P3OUT=BIT2; 
   P4OUT=a[p2]; 
   delay(); 
   P3OUT=BIT2 ; 
   P4OUT=0x7f; 
   delay(); 
  P3OUT=BIT1; 
  P4OUT=a[p3]; 
   delay(); 
  P3OUT=BIT0; 
   P4OUT=a[p4]; 
   delay(); 
  }   


#pragma vector = ADC10_VECTOR //ADC10 interrupt service__interrupt 
void adc_isr(void) 

 ad_value=ADC10MEM; 
 _B IC _SR_ IRQ (CPUOFF); 


Keywords:msp430  ADC10 Reference address:MSP430 uses ADC10 to measure the voltage of the temperature diode inside the chip

Previous article:12864 Display Menu Program
Next article:msp430 ADC10 single channel multiple conversions

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号