Consider the C code in Figure 7 for the dsPIC33EP64MC502 microcontroller. To rec
ID: 2081565 • Letter: C
Question
Consider the C code in Figure 7 for the dsPIC33EP64MC502 microcontroller. To receive credit, justify your answer to each of the following questions. (a) Which PORTA and PORTB bits are used for digital input? (b) Which PORTA and PORTB bits are used for digital output? Consider the circuit diagram in Figure 8 and the C code in Figure 9 for the dsPIC33EP64MC502 microcontroller. Justify your answer to each of the following questions using a few short sentences. (a) Correct and describe the purpose of line 18 in the C code in Figure 9. (b) 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) How must the code be modified so that the LED remains off, even after the microcontroller has been powered on for several hours.Explanation / Answer
1.
b) fror port A : hex to binary conversion : 0x12 = 0000000000010010
here all 0 can be used as digital output and 1 can be used as digital input.
for port B : hex to binary conversion : 0xD5FA = 1101010111111010
so for port A bit 0,2,3,5...15 can be used as digital output and
for port B bit 0,2,9,11,13 can be used as digital output.
a)
so for port A bit 1,4 can be used as digital input and
for port B bit 1,3,4...8,10,12,14,15 can be used as digital input.
2.
a) TRISB sets port direction, PORTB is usually used to read/write the port pin values, and there is LATB in some cases, that is used to set the pins to the wanted value.
TRISBbits.TRISB14 = 0 ; will set bits as as an output bit. - line also corrected.
b) Here 5000 ms= 5 ses delay is provided so LED will blink after every 5 sec.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.