Sunday, 18 October 2020

CCS code - Graph utility (temperature monitoring)

Do check the youtube video on Graph Tool of CCS : 


Do SUBSCRIBE to my channel!

I have used this code for temperature monitoring: 


#include <msp430g2553.h>


int temp = 0;

int temp1 =0;

void main(void){

WDTCTL = WDTPW | WDTHOLD; //stop the watchdog timer



//Select 1.5 V, 64 clock cycles, enable ADC interrupt, Turn on the reference generator

ADC10CTL0 = SREF_1 + REFON + ADC10ON + ADC10SHT_3 + ADC10IE;


//Select input channel 10 and divide the clock frequency by 4

ADC10CTL1 = INCH_10 + ADC10DIV_3;


while(1){

//Enable and Start conversion

ADC10CTL0 |= ENC + ADC10SC;


//Enter low power mode

__bis_SR_register(LPM0_bits + GIE);


//fetch the temperature value from ADC10MEM register

temp1 = ADC10MEM;


//convert it into degree celsius

temp = ((temp1 * 27069L - 18169625L)>>16);


}

}


//ISR

#pragma vector = ADC10_VECTOR

__interrupt void adc_interrupt(void)


{

__bic_SR_register_on_exit(CPUOFF);

}


No comments:

Post a Comment