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);

}


Sunday, 27 September 2020

MSP430 with a DC motor

The explanation for this project can be found here: Video explanation

Subscribe to the channel for more such content.

Below is the code:


#include <msp430g2553.h>

int count = 0;
void main()
{
WDTCTL = WDTPW | WDTHOLD;   // Stop watchdog timer

P1DIR |= BIT6|BIT2;
P1SEL |= BIT6; //P1.6 TA0.1 output signal for DC motor
P1OUT &= ~(BIT2);  //P1.2 for DC motor 

P1DIR &= ~BIT3; //Button P1.3
P1REN |= BIT3;
P1OUT |= BIT3;
P1IE |= BIT3;
P1IES |= BIT3;
CCR0 = 1000-1;
CCTL1 = OUTMOD_7;

__enable_interrupt();
__low_power_mode_0();



}
#pragma vector=PORT1_VECTOR
__interrupt void P1_Func()
{
int i = 0;
count = count + 1;
switch (count)
{
case 1: CCR1 = 850-1;
TACTL = TASSEL_2 + MC_1;
break;
case 2: CCR1 = 250-1;
count = 0;
break;
}

while(i<500)
{
if((P1IN&BIT3))
i++;
else
i=0;
}
P1IFG &= ~BIT3;
}