Question: Exercise 1 1) Write a C statement to define PORTD pins as inputs and copy its value in a variable X 2) Write a C
Exercise 1
1) Write a C statement to define PORTD pins as inputs and copy its value in a variable X
2) Write a C statement to define PORTC pins as outputs and display the decimal number 200 through these pins
3) Write a C statement to define PORTA<0> as output and drive high its corresponding pin
4) Write a C statement to define PORTD<3> as input and copy its value in X (1bit variable)
Exercise 2 Write C statements to create a time delay of 25ms assuming a microcontroller working at a frequency of 4 MHz.
Exercise 3 Write C statements to create a time delay of 10min assuming a microcontroller working at a frequency of 1 MHz.
Exercise 4 Write an algorithm and translate it to a C program to compute the 20 successive powers of a 8 bit number and store them in an array table. The number is red through PORTC.
Exercise 5 Write an algorithm and translate it to a C program to generate a periodic signal on PORTC<1> with a frequency of 1KHz. We assume the microcontroller is operating at a frequency of 1MHz.
Exercise 6 Write an algorithm and translate it to a C program for an embedded system that is used to control the access to a room. Users have to swipe their Id cards in order to unlock the door. The Id number is read through one of the PIC18 ports. The magnetic system that is used to lock or unlock the door is connected to one of PIC18F pins through a relay. If the voltage of this pin is 5 V (high) then the door opens for 20sec.
Exercise 7 Write an algorithm and translate it to a C program for a calculator that performs three (3) operations on 1byte numbers: addition, subtraction, and multiplication. The type of operation performed depends on the input op_code as follows if op_code=1 the calculator performs addition of the two 1byte numbers and store the result in Sum if op_code=2 the calculator performs subtraction of the two 1byte numbers and store the result in Difference if op_code=3 the calculator performs multiplication of the two 1byte numbers and store the result in the PRODH and PRODL if op_code is not equal to any of these values the system outputs Error=1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
