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

nteresting probles 1. In the system below a push button switch has been attached

ID: 2266084 • Letter: N

Question

nteresting probles 1. In the system below a push button switch has been attached to GPIO Port A3 and a transistor with an LED has been attached to GPIO Port B2. Write a sequence in ARM assembly code to run forever and turn on the LED as long as the switch is closed. You may assume that has been set up as input and GPIOB has been set up as output and the port clocks have been enabled. The address of GPIOA_IDR is 0x40020010 and the address of GPIOB_ODR is 0x40020414 GPIOA +5 ARM Nucleo Board Rc LED +5 Rb GPIOB 2

Explanation / Answer

#include<reg52.h> // special function register declarations

//program A

sbit pin0 = P1^0; //Defining pin0 PIN

sbit pin1 = P1^1; //Defining pin1 PIN

sbit LED = P3^0; //Defining pin1 PIN

void main (void)

{

P1 = 0X03; // Making P1.0 ad P1.1 as inputs

while(1) //infinite loop

{

if(pin1 == 1 ) //If pin1 is open P1.1 =1

{

if(pin0 == 0 ) //If Push button is pressed P1.0 will be zero

{

LED=0; //led connected in active low connection. So it will on for P3.0=0

}

else

{

LED=1;

}

}

else

{

LED=1;

}

}

#include<reg52.h> // special function register declarations

//program A

sbit pin0 = P1^0; //Defining pin0 PIN

sbit pin1 = P1^1; //Defining pin1 PIN

sbit LED = P3^0; //Defining pin1 PIN

void main (void)

{

P1 = 0X03; // Making P1.0 ad P1.1 as inputs

while(1) //infinite loop

{

if(pin1 == 0 ) //If pin1 is closed P1.1=0

{

if(pin0 == 1 ) //If Push button is open P1.0 =1

{

LED=0; //led connected in active low connection. So it will on for P3.0=0

}

else

{

LED=1;

}

}

else

{

LED=1;

}

}