Hi, i was interfacing LM35 to MSP430 launch pad (MSP430g2452), and the LM35 is connected to analog channel A4 of launch pad, The code is mentioned below, I'm getting a constant output as 23 deg C, I have got held up with this code for very long time and the temperature is not changing according to the change in the environment, Pls help me in resolving this issue, Expecting a positive and speedy reply.
Thanking you
#include "msp430g2452.h"
#include <stdio.h>
#include "adc_lcd16.h"
long temp;
long IntDegF;
long IntDegC;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1OUT = 0x00;
P1DIR |= 0xFF;
lcdinit();
ADC10CTL1 = INCH_4 + SHS_0 + ADC10SSEL_0 + ADC10DIV_4 + CONSEQ_0 ;
ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON + ADC10IE;
__enable_interrupt(); // Enable interrupts.
TACCR0 = 30; // Delay to allow Ref to settle
TACCTL0 |= CCIE; // Compare-mode interrupt.
TACTL = TASSEL_2 | MC_1; // TACLK = SMCLK, Up mode.
LPM0; // Wait for delay.
TACCTL0 &= ~CCIE; // Disable timer Interrupt
__disable_interrupt();
while(1)
{
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
__bis_SR_register(CPUOFF + GIE); // LPM0 with interrupts enabled
temp = ADC10MEM;
IntDegF = (temp/6.82)+33.8;
gotoXy(0,0);
prints("TEMP Deg F= ");
integerToLcd(IntDegF);
temp = ADC10MEM;
IntDegC=(temp/6.82);
gotoXy(0,1);
prints("TEMP Deg C= ");
integerToLcd(IntDegC);
ADC10CTL0&= ~ENC;
while(1)
{
}
__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=TIMER0_A0_VECTOR
__interrupt void ta0_isr(void)
{
TACTL = 0;
LPM0_EXIT; // Exit LPM0 on return
}