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

7. Programming problem (conditional branch) (25pts) Assume initialization and st

ID: 3835027 • Letter: 7

Question

7. Programming problem (conditional branch) (25pts) Assume initialization and start code are provided. Use conditional branch to complete the code in loop for following program. PF4 is switch input (1 swi is not pressed o means means SW1 is pressed) blue LED) PF2 is LED output (1 activates The specific operation of this system (enable 1) Make PF2 an output and make PF4 an input PUR for PF4) the LED ON (make PE2 from 2) The system starts with decrementing 3) Delay for less than 1 ms (start 8 OO (PE4 is o) then toggle 4) If the switch is pressed the LED once, else turn the LED ON 5) Repeat steps 3 and 4 over and over Init Start BL Init LDR RO GPIO PORTE DATA R. LDR R1, [RO] ORR R1, R1 Oxo8 STR RI, CRO] Loop

Explanation / Answer

The code to get LED output on pf2 is,

void EdgeCounter_Init(void){                         

  SYSCTL_RCGC2_R |= 0x00000020;

  FallingEdges = 0;

  GPIO_PORTF_DIR_R &= ~0x10; // pf4 built in button

    GPIO_PORTF_DIR_R |= 0x04;     //pf2 output

  GPIO_PORTF_AFSEL_R &= ~0x14;

  GPIO_PORTF_DEN_R |= 0x14;     //     Digital input/output pf4 and pf2

  GPIO_PORTF_PCTL_R &= ~0x000F0F00;

  GPIO_PORTF_AMSEL_R = 0;

  GPIO_PORTF_PUR_R |= 0x10;

GPIO_PORTF_IS_R &= ~0x10;   

  GPIO_PORTF_IBE_R &= ~0x10;

  GPIO_PORTF_IEV_R &= ~0x10;

  GPIO_PORTF_ICR_R = 0x10;   

  GPIO_PORTF_IM_R |= 0x10;

  NVIC_PRI7_R = (NVIC_PRI7_R&0xFF00FFFF)|0x00A00000;

  NVIC_EN0_R = 0x40000000;   

  EnableInterrupts();   

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote