Computer Course essay
// Lab 1: Startup code // 1 - Initialize Core // 2 - Initialize LEDs // Three - Initialize buttons // Four - logic to manage the LEDs based mostly on buttons: // If Right_button (SW2) is pressed, activate the RED LED // If Left_button (SW1) is pressed, activate the GREEN LED // If Both_buttons are pressed, activate the BLUE LED // // Lab project: // 1- Import the startup undertaking into your workspace, and confirm the startup code is working as anticipated, i.e. because it was demonstrated throughout the lab // Modify the code as follows, utilizing the supplied 1ms delay operate: // 2- When the Right_button (SW2) is pressed (and held), RED LED begins flashing at 2 HZ // Three- When the LEFT_button (SW1) is pressed (and held), GREEN LED begin flashing at 1 HZ // Four- When Each buttons are Right_button (SW2) is pressed, WHITE LED (Mixture of the three LEDs begin flashing at 5 HZ) // 5- Create a brief video demonstrating the performance by describing the code implementation together with the conduct // 6- Create the lab report based mostly on the report template, describe the carried out options in full element by creating an expert documentation // 7- Add the report, video, and your modified code to CANVAS #embody #embody "inctm4c123gh6pm.h" // Purple LED linked to PF1 on the Launchpad // Blue LED linked to PF2 on the Launchpad // Inexperienced LED linked to PF3 on the Launchpad #outline RED_LED 0x02 // PF1 #outline BLUE_LED 0x04 // PF2 #outline GREEN_LED 0x08 // PF3 // Coloration LED(s) PortF // darkish --- Zero // crimson R-- 0x02 // blue --B 0x04 // inexperienced -G- 0x08 // yellow RG- 0x0A // sky blue -GB 0x0C // white RGB 0x0E // pink R-B 0x06 #outline YELLOW_LED (RED_LED | GREEN_LED) #outline SKY_BLUE_LED (GREEN_LED | BLUE_LED) #outline WHITE_LED (RED_LED | GREEN_LED | BLUE_LED) #outline PINK_LED (RED_LED | BLUE_LED) #outline LED_OFF (Zero) #outline TRUE 1 #outline FALSE Zero // Damaging logic switches linked to PF0 and PF4 on the Launchpad #outline SW1 0x10 // PF0: on the left aspect of the Launchpad board #outline SW2 0x01 // PF4: on the proper aspect of the Launchpad board // capabilities prototypes: void PortF_Init(void); uint32_t PortF_Input(void); void PortF_Output(uint32_t knowledge); void delay_1ms (uint32_t delay); // Button states: uint8_t ButtonState_L; uint8_t ButtonState_R; uint8_t ButtonState_RL; // ButtonStates variable: uint32_t ButtonStates; // LED Command uint32_t LED_Command; int predominant(void) PortF_Init(); // initialize PF0 and PF4 and make them inputs // make PF3-1 outputs, PF3-1 built-in LEDs) // do ceaselessly, identical as for(;;) whereas(1) = ((ButtonState_RL) ? BLUE_LED : LED_OFF); if(LED_Command == LED_OFF) LED_Command = WHITE_LED; PortF_Output(LED_Command); change(ButtonStates) //1-SW1 pressed SW1 = 0x01 case (SW1): PortF_Output(RED_LED); delay_1ms(250); PortF_Output(LED_OFF); delay_1ms(250); break; //2-SW2 pressed SW2 = 0x10 case (SW2): PortF_Output(GREEN_LED); delay_1ms(250); PortF_Output(LED_OFF); delay_1ms(250); break; //Three-SW1 & SW2 pressed SW1 & SW2 = 0x11 case (SW1 & SW2): PortF_Output(BLUE_LED); delay_1ms(250); PortF_Output(LED_OFF); delay_1ms(250); break; //whereas loop // predominant operate //////////////////////////////////////// // // void PortF_Init(void) // /////////////////////////////////////// void PortF_Init(void) b a //////////////////////////////////////// // // uint32_t PortF_Input(void) // /////////////////////////////////////// uint32_t PortF_Input(void) SW2)); //////////////////////////////////////// // // PortF_Output(uint32_t knowledge) // /////////////////////////////////////// void PortF_Output(uint32_t knowledge) // write PF3-PF1 outputs GPIO_PORTF_DATA_R = knowledge; //////////////////////////////////////// // // delay_1ms (uint32_t delay) // /////////////////////////////////////// // Delay estimation: // Every delay loop will take roughly 160 cycles // Every cycle takes 1/16MHZ = 62.5ns // We have to create a 1ms delay //#outline DELAY_1ms (1000000)/(10*62.5) // roughly 1ms delay at ~16 MHz clock #outline DELAY_1ms 1000000/(625) // roughly 1ms delay at ~16 MHz clock 1500 // Please Observe: In fact Spin loop delay IS NOT the popular method to create delays, // This technique is used for now solely to reveal the LED performance // Timers can be used as an alternative ( and/or Software program timers are used to handle time-based delays) void delay_1ms (uint32_t delay) -research paper writing service