Question: //Convert this C code to Assembly code /* p2_1.c Toggling LEDs in C using registers by addresses */ /* This program toggles all three LEDs

//Convert this C code to Assembly code

/* p2_1.c Toggling LEDs in C using registers by addresses */ /* This program toggles all three LEDs for 0.5 second ON and 0.5 second OFF.*/

/*PF1 - red LED PF2 - blue LED PF3 - green LED They are high active (a '1' turns ON the LED).*/

#include "TM4C123GH6PM.h" #include #define SCB_CPAC (*((volatile unsigned int*)0xE000ED88)) /* PORTF data register */ // #define PORTBDAT (*((volatile unsigned int*)0x400053FC)) /* PORTF data direction register */ //#define PORTBDIR (*((volatile unsigned int*)0x40005400)) /* PORTF digital enable register */ //#define PORTBDEN (*((volatile unsigned int*)0x4000551C)) /* run mode clock gating register */ //#define RCGCGPIO (*((volatile unsigned int*)0x400FE608)) /* coprocessor access control register */ //#define SCB_CPAC (*((volatile unsigned int*)0xE000ED88))

void delayMs(int n); /* function prototype for delay */

int main(void) { SYSCTL->RCGCGPIO |= 0x22; GPIOF->LOCK = 0x4C4F434B; GPIOB->DIR = 0xFF; GPIOF->CR= 0x01; GPIOB->DEN = 0xFF; GPIOF->PUR = 0x11; GPIOF->DEN = 0x1F; GPIOF->DIR &= ~0x11; GPIOB->DATA= 0x21; //GPIOB->LOCK = 0x400FE608; /* unlock commit register */ while(1) { GPIOB->DATA = 0x21; delayMs(5000); while((GPIOF->DATA & 0x01)== 0x01) { } //ey nr GPIOB->DATA= 0x22; delayMs(2000); //2.7 red GPIOB->DATA = 0x0c; delayMs(5000); while((GPIOF->DATA & 0x10)== 0x10) { } //ey nr GPIOB->DATA = 0x14; delayMs(2000); } }

/* delay n milliseconds (16 MHz CPU clock) */ void delayMs(int n) { int i, j; for(i = 0 ; i < n; i++) for(j = 0; j < 3180; j++) {} /* do nothing for 1 ms */ }

/* This function is called by the startup assembly code to perform system specific initialization tasks. */ void SystemInit(void) { /* Grant coprocessor access*/ /* This is required since TM4C123G has a floating point coprocessor */ SCB_CPAC |= 0x00F00000; }

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