Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using msp430g2553 series turn this code from polling to interrupts using c language #include #define BUTTON1 ((P2IN & 0x02)== 0x00) #define BUTTON2 ((P2IN & 0x04)==

Using msp430g2553 series turn this code from polling to interrupts using c language
#include
#define BUTTON1 ((P2IN & 0x02)== 0x00)
#define BUTTON2 ((P2IN & 0x04)== 0x00)
#define BUTTON3 ((P2IN & 0x08)== 0x00)
#define BUTTON4 ((P2IN & 0x10)== 0x00)
#define B1 (P1IN & 0x10)
#define B2 (P1IN & 0x20)
#define B3 (P1IN & 0x40)
#define B4 (P1IN & 0x80)
#define YellowLedOn (P1OUT |= 0x01)
#define GreenLedOn (P1OUT |= 0x02)
#define RedLedOn (P1OUT |= 0x04)
#define AllLedsOff (P1OUT &= ~0x07)
/**
* main.c
*/
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
int Control = 0;
int NewPassWord[4];
int YourPassWord[4];
int EnterNewPassword = 0;
int EnterYourPassword = 0;
P2SEL = 0x00;
P1DIR = 0x0F;
P2DIR = 0xE1;
P1REN = 0xF0;
P2REN = 0x1E;
P1OUT = 0xF0;
P2OUT = 0x1E;
while(1){
if (Control == 0){
if (BUTTON1){
EnterNewPassword = 1;
}
if (EnterNewPassword == 1){
AllLedsOff;
NewPassWord[0] = B1;
NewPassWord[1] = B2;
NewPassWord[2] = B3;
NewPassWord[3] = B4;
if (BUTTON2){
EnterNewPassword = 0;
YellowLedOn;
Control = 1;
}
}
}
if (Control == 1){
if (BUTTON3){
EnterYourPassword = 1;
}
if (EnterYourPassword == 1){
YourPassWord[0] = B1;
YourPassWord[1] = B2;
YourPassWord[2] = B3;
YourPassWord[3] = B4;
if (BUTTON4){
EnterNewPassword = 0;
if ((YourPassWord[0] == NewPassWord[0])&& (YourPassWord[1] == NewPassWord[1])
&& (YourPassWord[2] == NewPassWord[2])&& (YourPassWord[3] == NewPassWord[3])){
AllLedsOff;
GreenLedOn;
Control = 0;
}
else{
AllLedsOff;
RedLedOn;
}
}
}
}
}
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Visual C# And Databases

Authors: Philip Conrod, Lou Tylee

16th Edition

1951077083, 978-1951077082

More Books

Students also viewed these Databases questions

Question

Discuss the techniques of job analysis.

Answered: 1 week ago

Question

How do we do subnetting in IPv6?Explain with a suitable example.

Answered: 1 week ago

Question

Explain the guideline for job description.

Answered: 1 week ago

Question

What is job description ? State the uses of job description.

Answered: 1 week ago

Question

What are the objectives of job evaluation ?

Answered: 1 week ago

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago