Question

Write the C-language instructions to: 4. Configure port D, pins 0-4 for output and 5-7 for input. Enable pull-up resistance o
0 0
Add a comment Improve this question Transcribed image text
Answer #1

To configure a port as input or output DDRx instruction is used. If the particular pin has value 0 then it is configured as input, if 1 is set then it is configured as output. For first 5 pins to be set as output we need 11111 value, for 5-7 pins as input we need 000. First bit starts from right and last bit ends towards the left.

DDRD =0b00011111;

Converting to hex,

DDRD = 0x1F; //serves required purpose

To enable pull-up resistance on input pins use PORTx instruction. If a PIN is set to 1 in PORT instruction, the enable resistance is enabled. If it has a value 0 then the pull-up resistance is disabled. If disabled, the PINs go in tri-state where their value cant be determined which can lead to problems in circuit further. To enable PIN 5 and 6, set them to 1 in PORTx.

PORTD = 0b01100000;

PORTD = 0x60;

These instructions serve the purpose,

DDRD = 0x1F;

PORTD = 0x60;

Add a comment
Know the answer?
Add Answer to:
Write the C-language instructions to: 4. Configure port D, pins 0-4 for output and 5-7 for...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT