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

MSP430- Code Composer Use the left button (S1) to decrease the LED1 frequency by

ID: 2080512 • Letter: M

Question

MSP430- Code Composer

Use the left button (S1) to decrease the LED1 frequency by a reasonable amount

(a factor of about 1.4 is suggested). Use the right button (S2) to increase the LED1 frequency

in a similar fashion. Each button press should make a single rate adjustment; greater adjustment will

require repeated presses. These buttons should adjust the LED1 frequency within a range of perceptible

frequencies, such as 0.1 Hz to 15 Hz. The precise frequencies are not critical as long as observable

changes are evident. If the rate is too high, you won’t be able to observe that the LED is actually flashing.

If the highest or lowest rate is reached, further button presses should be ignored if they attempt to venture

beyond the frequency range. For an ignored button press, do not illuminate LED2. This way, the user gets

feedback about the effectiveness of their button presses. Once completed, your program should allow you

to control the LED1 flash rate with the two push buttons: left for slower and right for faster. LED2 should

light up for every button press that successfully modifies the flash rate.

This code make the LED1 blink:

Explanation / Answer

#include <msp430.h>
long int x=245760,i=0;

void main(void)
{
WDTCTL = WDTPW + WDTHOLD;   
P1DIR |= BIT0;   
while (1)
{

P1OUT ^=0X01;

for(i=0;i<x;i++)
{
   if (P1IN & BIT4)
   x=1.4*x;
   if(P2IN & BIT1)
   x=x/1.4;   
   if(x>245760)
       x=245760;
   if(x<16384)
       x=16384;
}

}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote