Hello,
I found this TI code on internet (I use a MSP430F2274) :
//******************************************************************************
// MSP430F22x4 Demo - ADC10, Sample A10 Temp and Convert to oC and oF
//
// Description: A single sample is made on A10 with reference to internal
// 1.5V Vref. Software sets ADC10SC to start sample and conversion - ADC10SC
// automatically cleared at EOC. ADC10 internal oscillator/4 times sample
// (64x) and conversion. In Mainloop MSP430 waits in LPM0 to save power until
// ADC10 conversion complete, ADC10_ISR will force exit from LPM0 in
// Mainloop on reti. Temperature in oC stored in IntDegC, oF in IntDegF.
// Uncalibrated temperature measured from device to device will vary with
// slope and offset - please see datasheet.
// ACLK = n/a, MCLK = SMCLK = default DCO ~1.2MHz, ADC10CLK = ADC10OSC/4
//
// MSP430F22x4
// -----------------
// /|\| XIN|-
// | | |
// --|RST XOUT|-
// | |
// |A10 |
//
// A. Dannenberg
// Texas Instruments Inc.
// October 2006
// Built with CCE Version: 3.2.0 and IAR Embedded Workbench Version: 3.41A
//******************************************************************************
#include "msp430x22x4.h"
long temp;
volatile long IntDegC;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
BCSCTL1 = CALBC1_1MHZ; // Set DCO to 1MHz
DCOCTL = CALDCO_1MHZ;
ADC10CTL1 = INCH_10 + ADC10DIV_3; // Temp Sensor ADC10CLK/4
ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON + ADC10IE;
TACCR0 = 30; // Delay to allow Ref to settle
TACCTL0 |= CCIE; // Compare-mode interrupt
TACTL = TASSEL_2 + MC_1; // TACLK = SMCLK, Up mode
__bis_SR_register(CPUOFF + GIE); // LPM0, TA0_ISR will force exit
TACCTL0 &= ~CCIE; // Disable timer Interrupt
while(1)
{
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
__bis_SR_register(CPUOFF + GIE); // LPM0 with interrupts enabled
// oC = ((A10/1024)*1500mV)-986mV)*1/3.55mV = A10*423/1024 - 278
temp = ADC10MEM;
IntDegC = ((temp - 673) * 423) / 1024;
__no_operation(); // SET BREAKPOINT HERE
}
}
// ADC10 interrupt service routine
#pragma vector=ADC10_VECTOR
__interrupt void ADC10_ISR(void)
{
__bic_SR_register_on_exit(CPUOFF); // Clear CPUOFF bit from 0(SR)
}
#pragma vector=TIMERA0_VECTOR
__interrupt void TA0_ISR(void)
{
TACTL = 0; // Clear Timer_A control registers
__bic_SR_register_on_exit(CPUOFF); // Clear CPUOFF bit from 0(SR)
}
This code allows us to manage the conversion of the ADC10 but I don't know on which pin of the microcontroller I have to connect my temperature sensor. Because I want to convert the analog tension, that the sensor provide, to a digital tension, to finally determine the temperature. And I really want to know how to change the code to read the tension. please help me... ^^
Thank's for your time,
Matthias