Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 15: (25 points) 1. (10 points) Consider the C code in Figure 7 for the d

ID: 2081549 • Letter: P

Question

Problem 15: (25 points) 1. (10 points) Consider the C code in Figure 7 for the dsPIC33EPG4MC502 microcontroller. To receive credit, justify your answer to each of the following questions. (a) (5 points) Which PORTA and PORTB bits are used for for digital input? (b) (5 points) Which PORTA and PORTB bits are used for for digital output? 1 E void initialize IO ports (void) ANSELA. AINSELB 0; TRISA. Oxi2 TRISB xD5EA Figure 7: C code for the sPI microcontroller. 2. (15 points) Consider the circuit diagram in Figure 8 snd the C code in Figure 9 for the dsPIC33EP64MC502 microcontroller. Justify your answer to each of the following questions using a few short sentences. (B) (3 points) Correct and describe the purpose of line 18 in the C code in Figure 9. (b) (6 points) Describe the behavior of the LED after the code is deployed and the microcontroller is restarted by momentarily powering it off and then on. (c (6 points) How must the code be modified so that the LED remains off, even after the microcontroller has been powered on for several hours. LED 3300 Figure 8: Microcontroller I/O connections.

Explanation / Answer

A ‘1’ indicates that particular pin on port A is set as input. Also the right most bit corresponds to pin 0 and and left most bin corresponds to pin 7. Thus

Pin 0 on port A – output

Pin 1 on port A – input

Pin 2 on port A – output

Pin 3 on port A – output

Pin 4 on port A – input

Pin 5 on port A – output

Pin 6 on port A – output

Pin 7 on port A – output

RB15 = 1 = Input

RB14 = 1 = Input

RB13 = 0 = Output

RB12= 1 = Input

RB11= 0 = Output

RB10 = 1 = Input

RB9= 0 = Output

RB8 = 1 = Input

RB7 = 1 = Input

RB6 = 1 = Input

RB5 = 1 = Input

RB4 = 1 = Input

RB3 = 1 = Input

RB2 = 0 = Output

RB1 = 1 = Input

RB0 = 0 = Output

2 a. THe pin should be declared as output port to connect to LED and drive the LED

Hence the statement should be TRISBbits.TRISB14 = PORT_OUTPUT;

b. WHen the microcontroller is switched on, the LED is driven logic 1 for 5000mS i.e., 5S and after that it becomes off.

c. If the lines 20 and 21 are removed, the LED remians off, even after the microcontroller is powered on.