Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you help me find the error please is for msp430g2553 and is to 3 axis sensor #include msp430g2553.h #include lcd.h #define LED1 BIT0 int

Can you help me find the error please is for msp430g2553 and is to 3 axis sensor

#include "msp430g2553.h"

#include "lcd.h"

#define LED1 BIT0

int itoa(int n, char* out);

void reverse(char* str, int length);

//int temp;

char buffer[33];

char buffer2[33];

char buffer3[33];

int itoa(int n, char* out)

{

// if negative, need 1 char for the sign

int sign = n < 0? 1: 0;

int i = 0;

if (n == 0) {

out[i++] = '0';

} else if (n < 0) {

out[i++] = '-';

n = -n;

}

while (n > 0) {

out[i++] = '0' + n % 10;

n /= 10;

}

out[i] = '\0';

reverse(out + sign, i - sign);

return 0;

}

void reverse(char* str, int length){

int i = 0, j = length-1;

char tmp;

while (i < j) {

tmp = str[i];

str[i] = str[j];

str[j] = tmp;

i++; j--;

}

}

int main(void)

{

WDTCTL = WDTPW + WDTHOLD; //Stop WDT

BCSCTL1 = CALBC1_8MHZ; //Set DCO to 8Mhz

DCOCTL = CALDCO_8MHZ; //Set DCO to 8Mhz

P1DIR &= ~0xF0; // set pin direction for led

P1DIR |= BIT0;

P2DIR&=~BIT3;

InitializeLcm(); //INITIALIZE LCD

__delay_cycles(1000000);

__enable_interrupt();

int value;

char *text;

while(1)

{

ADC10CTL1 = INCH_3 + ADC10DIV_3 ;

ADC10CTL0 = SREF_0 + ADC10SHT_3 + ADC10ON + ADC10IE;

ADC10AE0 |= BIT3;

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

__bis_SR_register(CPUOFF + GIE); // LPM0 with interrupts enabled

value = ADC10MEM;

itoa(value,buffer);

ClearLcmScreen();

PrintStr("X="); //DISPLAY ON LCD

PrintStr(buffer);

__delay_cycles(100000); // Wait for ADC Ref to settle

ADC10CTL1 = INCH_4 + ADC10DIV_3 ;

ADC10CTL0 = SREF_0 + ADC10SHT_3 + ADC10ON + ADC10IE;

ADC10AE0 |= BIT4;

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

__bis_SR_register(CPUOFF + GIE); // LPM0 with interrupts enabled

value = ADC10MEM;

itoa(value,buffer2);

ClearLcmScreen();

PrintStr("Y="); //DISPLAY ON LCD

PrintStr(buffer2);

__delay_cycles(100000);

ADC10CTL1 = INCH_5 + ADC10DIV_3 ;

ADC10CTL0 = SREF_0 + ADC10SHT_3 + ADC10ON + ADC10IE;

ADC10AE0 |= BIT5;

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

__bis_SR_register(CPUOFF + GIE); // LPM0 with interrupts enabled

value = ADC10MEM;

itoa(value,buffer3);

ClearLcmScreen();

PrintStr("Z="); //DISPLAY ON LCD

PrintStr(buffer3);

__delay_cycles(100000);

}

}

// ADC10 interrupt service routine

#pragma vector=ADC10_VECTOR

__interrupt void ADC10_ISR (void)

{

__bic_SR_register_on_exit(CPUOFF); // Return to active mode

P1OUT ^= LED1;

}

// end of 3axisaccelerometer.c file

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

How do you use positive emphasis in a negative message?

Answered: 1 week ago

Question

Find x . Round your answer to the nearest tenth of a degree. \f

Answered: 1 week ago

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago