Question: Below is an example of a similar program for the given microcontroller/system this assignment will be performed on. It can be used as a reference

 Below is an example of a similar program for the given

Below is an example of a similar program for the given microcontroller/system this assignment will be performed on. It can be used as a reference if you would like the required addresses for setup, but the main program is what's needed.

#define GPIO_PORTF_DATA_R (*((volatile unsigned long *)0x400253FC)) #define GPIO_PORTF_DIR_R (*((volatile unsigned long *)0x40025400)) #define GPIO_PORTF_AFSEL_R (*((volatile unsigned long *)0x40025420)) #define GPIO_PORTF_PUR_R (*((volatile unsigned long *)0x40025510)) #define GPIO_PORTF_DEN_R (*((volatile unsigned long *)0x4002551C)) #define GPIO_PORTF_LOCK_R (*((volatile unsigned long *)0x40025520)) #define GPIO_PORTF_CR_R (*((volatile unsigned long *)0x40025524)) #define GPIO_PORTF_AMSEL_R (*((volatile unsigned long *)0x40025528)) #define GPIO_PORTF_PCTL_R (*((volatile unsigned long *)0x4002552C)) #define SYSCTL_RCGC2_R (*((volatile unsigned long *)0x400FE108)) // 2. Declarations Section // Global Variables unsigned long SW1,SW2; // input from PF4,PF0 unsigned long Out; // outputs to PF3,PF2,PF1 (multicolor LED) // Function Prototypes void PortF_Init(void); // 3. Subroutines Section // MAIN: Mandatory for a C Program to be executable int main(void){ PortF_Init(); // Call initialization of port PF4, PF3, PF2, PF1, PF0 while(1){ SW2 = !(GPIO_PORTF_DATA_R&0x10); // read PF4 into SW2 if(SW2){ // SW2 pressed GPIO_PORTF_DATA_R = 0x04; // LED is blue } else{ GPIO_PORTF_DATA_R = 0x00; // LED is off } } } // Subroutine to initialize port F pins for input and output // PF4 and PF0 are input SW1 and SW2 respectively // PF3,PF2,PF1 are outputs to the LED // Inputs: None // Outputs: None // Notes: These five pins are connected to hardware on the LaunchPad void PortF_Init(void){ volatile unsigned long delay; SYSCTL_RCGC2_R |= 0x00000020; // 1) F clock delay = SYSCTL_RCGC2_R; // delay GPIO_PORTF_LOCK_R = 0x4C4F434B; // 2) unlock PortF PF0 GPIO_PORTF_CR_R = 0x1F; // 3) allow changes to PF4-0 GPIO_PORTF_AMSEL_R = 0x00; // 4) disable analog function GPIO_PORTF_PCTL_R = 0x00000000; // 5) GPIO clear bit PCTL GPIO_PORTF_DIR_R = 0x0E; // 6) PF4,PF0 input, PF3,PF2,PF1 output GPIO_PORTF_AFSEL_R = 0x00; // 7) no alternate function GPIO_PORTF_PUR_R = 0x11; // 8) enable pullup resistors on PF4,PF0 GPIO_PORTF_DEN_R = 0x1F; // 9) enable digital pins PF4-PF0 } 

Write a c program that receives input from switch 1 and switch 2 , and output to the three LEDs, Red, Green, and Blue. Your program should work like this: Switch 1 pressed and switch 2 released LED Red goes on. Switch 1 released and switch 2 pressed LED Green goes on. Switch 1 pressed and switch 2 pressed LED Blue goes on. Switch 1 released and switch 2 released All LEDs off

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!