Question: Fix the broken C Code. The program should blink the Green LED every half second, but the Red LED is steadily lit. You may NOT

Fix the broken C Code. The program should blink the Green

LED every half second, but the Red LED is steadily lit. You

may NOT delete or add code, you may only change values

being stored in a variable or register.

Time an iteration of the delay subroutine using the CPU timer

and breakpoints.

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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!