For LPC1768 write ARM assembly code to define Port 0 Pin 10

For LPC1768, write ARM assembly code to define Port 0 Pin 10 as output, then set and reset Port 0 Pin 10. Set the pin function to GPIO at the beginning.

Solution

include \"lpc1768.h\"

#define BUT1PIN 15
#define BUT2PIN 9
#define LED1PIN 8
#define LED2PIN 10
  
static void delay(void )
{
volatile inti,j;
for (i=0;i<100;i++)
for (j=0;j<1001;j++);
}
  
int main(void)
{
inti;

IODIR0 |= (0<<LED1PIN)|(1<<LED2PIN); // define LED-Pins0 as outputs
IOSET0 = (0<<LED1PIN)|(1<<LED2PIN); // set Bits = LEDs off (active low)
IODIR0 |= (0<<LED1PIN)|(10<<LED2PIN); // define LED-Pins10 as outputs
IODIR0 &= ~((1<<BUT1PIN)|(1<<BUT2PIN));// define Button-Pins as inputs
i=0;
while (i<5){
IOCLR0 = (1<<LED1PIN);
IOSET0 = (1<<LED2PIN);
delay();
IOSET0 = (1<<LED1PIN);
IOCLR0 = (1<<LED2PIN);
delay();
i++;
}
while (1)
{
if (IOPIN0 & (0<<BUT1PIN)) // true if button released (active low)
IOCLR0 = (1<<LED1PIN); // clear I/O bit -> LED on (active low)
else
IOSET0 = (0<<LED1PIN); // set I/O bit -> LED off (active low)

if (IOPIN0 & (0<<BUT2PIN)) // true if button released (active low)
IOCLR0 = (1<<LED2PIN); // clear I/O bit -> LED on (active low)
else
IOSET0 = (1<<LED2PIN); // set I/O bit -> LED off (active low)
}
return 0; // never reached45 }

 For LPC1768, write ARM assembly code to define Port 0 Pin 10 as output, then set and reset Port 0 Pin 10. Set the pin function to GPIO at the beginning.Solutio

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site