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);
}
Previous article:12864 Display Menu Program
Next article:msp430 ADC10 single channel multiple conversions
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- 100k bridge
- Remove a chip from a DDR3 1600Mhz 4G memory stick and then put it back together
- 【RT-Thread Reading Notes】7. RT-Thread Study Chapters 8-12 Reading Notes
- What is Zigbee?
- 5G filter, duplexer professional design and production
- EEWORLD University ---- Introduction to Linux Kernel Programming
- Share your TouchGFX design and win an STM32F750 development board. Come on board!
- 【GD32E231 DIY】Remote Data Acquisition System
- Force Sensor Selection
- [Gravity:AS7341 Review] Color temperature perception measurement: reading data from four single channels one by one