Question: Question at position 2 2 Explain What the following code does. #include #define LED 1 ( 0 x 0 1 ) #define LED 2 (

Question at position 22 Explain What the following code does. #include #define LED1(0x01) #define LED2(0x01) #define S1(0x04) #define S2(0x40) void main(void){ volatile int OUT1[]={LED1, ~LED1, LED1, ~LED1, ~LED1, LED1, LED1, ~LED1}; volatile int OUT2[]={~LED2, LED2, LED2, ~LED2, LED2, LED2, ~LED2, LED1,}; volatile int TIME[]={40,10,50,20,50,15,30,15}; PM5CTL0 &= ~LOCKLPM5; WDTCTL = WDTPW + WDTHOLD; // stop Watch Dog Timer P1DIR |= LED1; // P1.0 directiLED1 for output P1OUT &= ~ LED1; //turn off LED1 P4DIR |= LED2; //P4.0 directiLED1 for output P4OUT &= ~ LED2; //turn off LED2 P1DIR &= ~S1; // S1 pin P1.2 set zero for input P1REN |= S1; // enable P1.2 internal resistor P1OUT |= S1; //enable P1.2 resistors for pull-up P2DIR &= ~S2; // S2 pin P2.6 set zero for input P2REN |= S2; // enable P2.6 internal resistor P2OUT |= S2; // enable P2.6 resistors for pull-up volatile unsigned int i; volatile unsigned int j; volatile unsigned int k; for (;;){ P1OUT &= ~LED1; P4OUT &= ~LED2; if(!(S1 & P1IN)){ while (S2 & P2IN){ for(i=0; i<8; i++){ if (OUT1[i]== LED1) P1OUT |= OUT1[i]; else if (OUT1[i]== ~LED1) P1OUT &= OUT1[i]; if (OUT2[i]== LED2) P4OUT |= OUT2[i]; else if (OUT2[i]== ~LED2) P4OUT &= OUT2[i]; for(j=0; j #define LED1(0x01) #define LED2(0x01) #define S1(0x04) #define S2(0x40) void main(void){ volatile int OUT1[]={LED1, ~LED1, LED1, ~LED1, ~LED1, LED1, LED1, ~LED1}; volatile int OUT2[]={~LED2, LED2, LED2, ~LED2, LED2, LED2, ~LED2, LED1,}; volatile int TIME[]={40,10,50,20,50,15,30,15}; PM5CTL0 &= ~LOCKLPM5; WDTCTL = WDTPW + WDTHOLD; // stop Watch Dog Timer P1DIR |= LED1; // P1.0 directiLED1 for output P1OUT &= ~ LED1; //turn off LED1 P4DIR |= LED2; //P4.0 directiLED1 for output P4OUT &= ~ LED2; //turn off LED2 P1DIR &= ~S1; // S1 pin P1.2 set zero for input P1REN |= S1; // enable P1.2 internal resistor P1OUT |= S1; //enable P1.2 resistors for pull-up P2DIR &= ~S2; // S2 pin P2.6 set zero for input P2REN |= S2; // enable P2.6 internal resistor P2OUT |= S2; // enable P2.6 resistors for pull-up volatile unsigned int i; volatile unsigned int j; volatile unsigned int k; for (;;)

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 Programming Questions!