Question: I want you to modify the code to meet the requirnments. Im using micro vision to program a TM4C123 microcontroller to perform a certain actions.

I want you to modify the code to meet the requirnments.

Im using micro vision to program a TM4C123 microcontroller to perform a certain actions.

i was able to write the code for the first part and i need to get the rest done.

its is mandatory to use one while loop, AND, OR, and Shifting operations only.

This is my piece of code: (I have all of the inputs, outputs and ports activated.)

#include "inc/tm4c123gh6pm.h"

int initialPortB(void);// fun prototype

int main(void){ initialPortB(); while(1){ int temp = GPIO_PORTB_DATA_R & 0x10;//collect switch's bit value temp = temp >> 3;//shifting the stored value 3 to the right GPIO_PORTB_DATA_R &= ~0x02; //clearing PB2 GPIO_PORTB_DATA_R |= temp; //setting PB2 } }

int initialPortB(void){ SYSCTL_RCGC2_R |= 0x02;//initi. PortB GPIO_PORTB_DIR_R |= 0x42; //input pins GPIO_PORTB_DIR_R &=~0x10;//output pins GPIO_PORTB_AMSEL_R &=~0x52;//disable GPIO_PORTB_DEN_R |= 0x52;//enable digital I/O GPIO_PORTB_AMSEL_R &=~0x52;//disable return 0; }

The labs guidline:

3.3.1 Specifications:.

Input pin: PB4 connects to switch, positive logic.

Output pin: PB1 connects to LED1, positive logic.

3.3.2 Requirements:

When switch is not pressed, LED1 turns off.

When switch is pressed and hold at the same time, LED1 turns on.

3.4.1 Instruction:

Add the second LED (LED2) to the circuit that you designed in previous section. Connect LED2 in negative logic to PB6.

Modify your design so that when switch is not pressed, LED2 turns on. Otherwise, it turns off. LED 1 still follows same requirements designed in part 1.

Good luck!

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!