Write C code that initializes TM4C Port A, so pins 5, 4 and 3 are output. Comment your code to explain each initialization step clearly. Make the initialization friendly.
ans.................................................
reruired code in c:
Note:
here we take a function that takes a 3-bit parameters from 0 to 7
..................................................................................
#define GPIO_PORTE_DATA_R (((volatile unsigned long
)0x40024000))
#define GPIO_PORTE_DIR_R (((volatile unsigned long
)0x40024400))
#define GPIO_PORTE_AFSEL_R (((volatile unsigned long
)0x40024420))
#define GPIO_PORTE_PUR_R (((volatile unsigned long
)0x40024510))
#define GPIO_PORTE_DEN_R (((volatile unsigned long
)0x4002451C))
#define GPIO_PORTE_CR_R (((volatile unsigned long
)0x40024524))
#define GPIO_PORTE_AMSEL_R (((volatile unsigned long
)0x40024528))
#define GPIO_PORTE_PCTL_R (((volatile unsigned long
)0x4002452C))
#define SYSCTL_RCGC2_R (((volatile unsigned long )0x400FE108))
// 2. Declarations Section
// Global Variables
unsigned long sw; // input from PF4
unsigned long Out; // outputs to PF3,PF2,PF1 (multicolor LED)
// Function Prototypes
void PortE_Init(void);
void Delay(void);
int main(void){
PortE_Init(); // Call initialization of port E
while(1){
sw = GPIO_PORTE_DATA_R&0x08; // read PE4 into sw
if(sw == 0x00){ // if switch is pressed
GPIO_PORTE_DATA_R = 0x02; // LED is green
} else{
GPIO_PORTE_DATA_R = 0x04; // LED is red
}
Delay(); // wait 0.1 sec
GPIO_PORTE_DATA_R = 0x01; // LED is blue
Delay(); // wait 0.1 sec
}
}
// Subroutine to initialize port E pins for input and
output
// PE3 is an input from a switch SW
// PE2, PE1, PE0 are outputs to the LED
void PortE_Init(void){ volatile unsigned long delay;
SYSCTL_RCGC2_R |= 0x00000010; // 1) E clock
delay = SYSCTL_RCGC2_R; // delay
GPIO_PORTE_CR_R = 0x2F; // allow changes to PE5,3-0
GPIO_PORTE_AMSEL_R = 0x00; // 3) disable analog function
GPIO_PORTE_PCTL_R = 0x00000000; // 4) GPIO clear bit PCTL
GPIO_PORTE_DIR_R |= 0x08; // 5) PE3 input
GPIO_PORTE_DIR_R &=~ 0x07; // 5) PE2,PE1,PE0 output
GPIO_PORTE_AFSEL_R = 0x00; // 6) no alternate function
GPIO_PORTE_PUR_R = 0x08; // enable pullup resistors on PE3
GPIO_PORTE_DEN_R = 0x0F; // 7) enable digital pins PE3-PE0
}
// Subroutine to wait 0.1 sec
void Delay(void){unsigned long volatile time;
time = 727240*200/91; // 0.1sec
while(time){
time--;
}
}
Write C code that initializes TM4C Port A, so pins 5, 4 and 3 are output....
Write the C-language instructions to: 4. Configure port D, pins 0-4 for output and 5-7 for input. Enable pull-up resistance on pins 5 and 6.
0/3 D6.15 Write an assembly main program that implements this Mealy finite state machine. happy The FSM state graph, shown below, is givenP and cannot be changed. The input is on Port A bit 0 and the output is on Port B bits 3,2,1,0. There are three states (happy, hungry, sleepy), and initial state is happy. hungry 1/8 1/2 143 0/4 sleepy a) Show the ROM-based FSM data structure b) Show the initialization and controller software. Initialize the direction registers,...
Modify the following assembly code section in order to make: The pins 0 and 1 of PORTA inputs. All PORTB pins outputs, PORTB pins 7, 5, 3 & 1 have the logic value 1. BCF ST ATUS.RP0 MOVLW b'00000000' MOVWF TRISA MOVLW b'10101010 MOVWF TRlSB BSF STATUSRP0 MOVLW b'01010101 MOVWF TRtSB The register which indicates that exact part of the execution sequel where the program is running is called? Write just the assembly code section to evaluate the sum of...
Write assembly or C software to implement the following Mealy
FSM (Figure 2.42). Include the FSM state machine, port
initialization, timer initialization, and the FSM controller. The
command sequence will be input, output, wait 10 ms, input, then
branch to next state. The 1-bit input is on Port P (PP0), and the
3-bit output is on Port P (PP3, PP2, PP1). Assume the E clock is 8
MHz. Microcontroller MC9S12
0/4 Happy Hungry 1/2 1/5 1/3 06 Sleepy Figure 2.42...
2. Given the following setup for GPIO (fill in all the blanks, refer to pages 1-4) GPIOB_MODER 0x10000 //GPIOB_OTYPER is not needed as its default value is zero GPIOB_OSPEEDRI=0x3000; GPIOBPUPDRI= 0x80; - a. Which port is being initialized? Port b. Describe the important features from the initialization for pin 3 Ifor example input, output, alternate function, analog, pull up, pull down, push/pull, open drain out, speed, etc.). Px3 is initialized to be c. Which pin is being initialized as an...
Write a C program that will output clock signals to port 4 of MSP430. Assume that clock inputs are as follows: ACLK = LFXT1 = 32768, MCLK = DCO Max, SMCLK = XT2.
can you please solve in c and clear
1 - General purpose eneral purpose 1/0 [30 pts re going to use the DDR, PORT, and PIN registers from your AVR device ions are the same as your AVR device). Assume that your AVR has. LED2) connected to pins 0, 1, 2 of Port C, respectively. In this question, you are going (the register definitions are the san • I pushbutton connected to pin 3 and Port C • 3 LEDs...
Write a C program that initializes an integer array, and two scalar values a and b. Your program should multiply each elements of the array with a and add b to the product to form a new array output. Display the output array.
Question 3 (CLOS: 3.5) Marks: 4+4 = 8 (a) Write a code in java to make a class called Animal. The class has data attributes called name. Make one constructor which initializes value of name attribute (b) Make a class called Cat and make it children of Animal class. Declare a variable of the class called age. Make a constructor of this class which initializes both age and name of the class. Make a main method in the class and...
C++ Write code using 2 nested loops, that produces the following
output.
Write code using 2 nested loops, that produces the following output. 1 5 4 3 2 1 4 3 2 1 3 2 1 code.cpp New #include <iostream> 2 using namespace std; 3 4 int main() { 5 6 // TODO: your code go 7 8 9 2 1 1 }