Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The code should be change so that the msp430 will blink the green led and keep t

ID: 3885328 • Letter: T

Question

The code should be change so that the msp430 will blink the green led and keep the red led steadily lit.I have debugged thus far to light the red and green led.But cant figure out how to blink the green led. I tried changing the for loop but nothing.

#include /* * Fix this code! You may NOT delete or add code, you may only change values being stored in a variable or register.

*/ void DELAY(); unsigned int CLS(unsigned int x);

unsigned int CRS(unsigned int x);

int main(void) { WDTCTL = WDTPW | WDTHOLD;

volatile unsigned int m = 1;

volatile unsigned int s = 0;

volatile unsigned int p = 65535

; P1DIR |= m; while(s

) { p = CRS(p); P1OUT = p;

DELAY();

}

} void DELAY()

{ volatile unsigned int i = 25;

volatile unsigned int j = 0;

volatile unsigned int k = 1;

volatile unsigned int l = 0;

for(; i > 0; i--)

{ j += 2; k += 2; }

l = CLS(j + k);

}

unsigned int CLS(unsigned int x)

{

return (x << 1) | (x >> 15);

}

unsigned int CRS(unsigned int x)

{ return (x >> 1)| (x << 15); }

Explanation / Answer

the code now changed so far

#include <stdio.h>
void DELAY();

unsigned int CLS(unsigned int x);

unsigned int CRS(unsigned int x);
int main(void)

{

WDTCTL = WDTPW | WDTHOLD;
volatile unsigned int m = 1;
volatile unsigned int s = 0;
volatile unsigned int p = 65535;

P1DIR |= m; while(s)

{

p = CRS(p);

P1OUT = p;
DELAY();
}
}

void DELAY()
{

volatile unsigned int i = 25;
volatile unsigned int j = 0;
volatile unsigned int k = 1;
volatile unsigned int l = 0;
for(; i > 0; i--)
{

j += 2; k += 2;

}
l = CLS(j + k);
}
unsigned int CLS(unsigned int x)
{
return (x << 1) | (x >> 15);
}
unsigned int CRS(unsigned int x)
{

return (x >> 1)| (x << 15);

}