You are on page 1of 3

EXPERIMENT-7

OBJECTIVE: To write a program interface potentiometer with GPIO using MSP430.

APPARATUS REQUIRED: PC, MSP430 launch pad MSP-EXP430G2. etc.

SOFTWARE REQUIRED: Code composer studio

ALGORITHM:
1. Disables the watchdog timer.
2. Configure Port 1.0 as output.
3. Configure the Analog to digital converter.
4. Select the input channel.
5. Start sampling the analog input.
6. Compare the threshold.
7. Turn ON red LED.
8. Else turn off.

FLOW CHART

PROGRAM REQUIRED

#include <msp430.h>

int main(void)
{

WDTCTL = WDTPW + WDTHOLD; // Stop WDT

ADC10CTL0 = SREF_0 + ADC10SHT_2 + ADC10ON;

ADC10CTL1 = INCH_3; // input A3

ADC10AE0 |= 0x08; // PA.3 ADC option select

P1DIR |= 0x01; // Set P1.0 to output direction

while(1)

ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start

if (ADC10MEM < 512) // ADC10MEM = A3 > 512?

P1OUT &= ~0x01; // Clear P1.0 LED off

else

P1OUT |= 0x01; // Set P1.0 LED on

PROCEDURE

1. Check the program and debug it.


2. Connect the kit.
3. Load the program (hexfile) into the controller.
4. Check the results of the program.

RESULT

The program is executed on the msp430 and verified.

PRECAUTIONS

1. Verify the program before loading it on msp430.


2. Connect the modules to msp430 right and tight.
3. Make sure the msp430 kit is connected properly to the computer.

You might also like