Question

In: Electrical Engineering

1.write a program for the msp430 to make led 1 blink at 50 percent duty cycle....

1.write a program for the msp430 to make led 1 blink at 50 percent duty cycle. 2 modify the program to make led 1 blink 5 times, make a long pause, then blink 5 more times then stop. The time delays should be carried out in subroutines

Solutions

Expert Solution

Solution:

Two LEDs are connected to two Pins of Port-2

LED1- is connected to P2.2 (Port -2) and it is active high means that when the bit is high LED will glow.

The below program is implementation of alternative blinking of one LEDs with duty cycle of 50% by delay of 352msec ON and 352msec OFF. A separate subroutine is implemented for time delay.

Program1:

/******** Progrman for alternate blinking of one led with 50%dutycycle *******/

#include "msp430x14x.h"

#define BIT2 0x04u

#define BIT3 0x08u

void delay_352us(unsigned int i);//352us delay program statement

//*************************************

int main( void )

{

WDTCTL = WDTPW + WDTHOLD;// Stop watchdog timer to prevent time out reset

P2DIR |= BIT2;          //Port 2.2 as output port for led1

P2DIR |= BIT3;          //Port 2.3 as output port for led2

P2OUT &= ~BIT2;                  //led1 off        

P2OUT &= ~BIT3;                  //led2 off

while(1)

{

            P2OUT |= BIT2;                       //led1 on

            delay_352us(1000);    //delay of 352msec ON

            P2OUT &= ~BIT2;                    //led1 off        

            delay_352us(1000);          //delay of 352msec OFF

   }

}

//******************************************************

//352 ms delay procedure

void delay_352us(unsigned int i)//352us delay procedures, the calculation of delay time in front of already mentioned

{

unsigned char j;

while(i--)

{

   for(j=0;j<255;j++)

   {

    _NOP();

    _NOP();

    _NOP();

    _NOP();  

    }

}

} /******************end of program********/

Program2:

It is an implementation of following sequences for the two LEDs

  1. Blink LED1 – 5 times and long pause
  2. Blink LED1– 5 times and stop.

/******** Progrman for alternate blinking of two leds *******/

#include "msp430x14x.h"

#define BIT2 0x04u

#define BIT3 0x08u

void delay_352us(unsigned int i);//352us delay program statement

void blinkled1();

void blinkled2();

void blinkled1and2();

//*************************************

int main( void )

{

WDTCTL = WDTPW + WDTHOLD;// Stop watchdog timer to prevent time out reset

P2DIR |= BIT2;          //Port 2.2 as output port for led1

P2DIR |= BIT3;          //Port 2.3 as output port for led2

P2OUT &= ~BIT2;                  //led1 off        

P2OUT &= ~BIT3;                  //led2 off

blinkled1();

delay_352us(1000000);          //long pause

blinkled1();

}

/*******Blink LED1*****/

void blinkled1()

{

            unsigned char i=0;

            for(i=0;i<5;i++)

            {

                        P2OUT |= BIT2;                       //led1 on

                        delay_352us(1000);

                        P2OUT &= ~BIT2;                    //led1 off

                        delay_352us(1000);

           

            }          

}

//******************************************************

//352 ms delay procedure

void delay_352us(unsigned int i)//352us delay procedures, the calculation of delay time in front of already mentioned

{

unsigned char j;

while(i--)

{

   for(j=0;j<255;j++)

   {

    _NOP();

    _NOP();

    _NOP();

    _NOP();   

    }

}

}

/*****end of Program***************/

Three functions are defined for the two steps and it stops.


Related Solutions

1.write a program for the msp430FR6989 to make led 1 blink at 50 percent duty cycle....
1.write a program for the msp430FR6989 to make led 1 blink at 50 percent duty cycle. 2 modify the program to make led 1 blink 5 times, make a long pause, then blink 5 more times then stop. The time delays should be carried out in subroutines
1. Write a code that makes the MSP430 blink the red LED and the green LED...
1. Write a code that makes the MSP430 blink the red LED and the green LED at the same time. The two LEDs should be on at the same time and then off at the same time
1. IN C LANGUAGE: Write a code that makes the MSP430 blink the red LED and...
1. IN C LANGUAGE: Write a code that makes the MSP430 blink the red LED and the green LED at the same time. The two LEDs should be on at the same time and then off at the same time
Write a program for the msp430 to make led1 and led 2 alternate blinking 2. repeat...
Write a program for the msp430 to make led1 and led 2 alternate blinking 2. repeat the program to make each led blink 5 times in a sequence, then 5 times simultaneously
For the mspfr6989 write program #2 1(b) Write a program that will make LED1 blink 5...
For the mspfr6989 write program #2 1(b) Write a program that will make LED1 blink 5 times when S1 is pressed, and then stop. Program #2 – Using both S1 and S2 1 Write a program like 1(b) above, but the LED1 will blink until S2 is pressed. 2 Write a program that simulates a motor coming up to speed. When S1 is pressed, LED1 blinks at 50% duty cycle for 10 cycles (indicating a motor coming up to speed)....
Make a C program to blink/toggle a LED every second with the Atmega128 chip. Hint: Because...
Make a C program to blink/toggle a LED every second with the Atmega128 chip. Hint: Because the delay function has a maximum delay limit, you will need an internal counter to accumulate delays to one second. a) Write code that uses the timer interrupt for implementation. b) Write code that uses stopwatch on the second toggle in Atmel Studio
Make a C program to blink/toggle a LED every second with the Atmega128 chip. Hint: Because...
Make a C program to blink/toggle a LED every second with the Atmega128 chip. Hint: Because the delay function has a maximum delay limit, you will need an internal counter to accumulate delays to one second. a) Write code that uses the delay function for implementation b) Write code that uses a stopwatch on the third toggle
Write a function that can be used to blink an LED when called.
Write a function that can be used to blink an LED when called.
Write a C program to blink two LEDs connected to Raspberry pi. One must blink at...
Write a C program to blink two LEDs connected to Raspberry pi. One must blink at a rate of 1 Hz and the other at a rate of 2 HZ.
7. Write a C program to generate a 16kHz PWM signal that has 40% duty cycle...
7. Write a C program to generate a 16kHz PWM signal that has 40% duty cycle using Timer2 of an ATMega8 microcontroller.   8. Consider a push button switch SW0 connected to pin INT0 external interrupts of an ATMega8 AVR. 8 LEDS are connected to port PB0-PB7 on the same AVR. These LEDS are connected such a lit LED displays that the output port is on logic level 1. On start-up, TASK1 is executed and continue indefinitely. If the push-button switch...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT