1
\$\begingroup\$

I have a question related to AVR microcontrollers using AVR-GCC and CodeVision:
Normally we set the port related registers inside the main function using DDRx/PORTx registers, for example like this:

DDRB = 0x00;
PORTB = 0x00;

How can I change the content of these registers in other places of the program?

And another question, is it wise to set DDRx and PORTx registers using the following way:

DDRB.0=0;
PORTB.0=1;
alexan_e
11.3k1 gold badge30 silver badges62 bronze badges
asked Jul 29, 2013 at 8:17
\$\endgroup\$
3
  • \$\begingroup\$ This question would take too much introductory material to explain since you don't even understand this is a processor-specific question. \$\endgroup\$ Commented Jul 29, 2013 at 11:07
  • \$\begingroup\$ What introductory material? \$\endgroup\$ Commented Jul 29, 2013 at 16:20
  • \$\begingroup\$ Exactly. ------ \$\endgroup\$ Commented Jul 29, 2013 at 18:15

1 Answer 1

2
\$\begingroup\$

Exactly the same way; there is no intrinsic difference between performing the assignment at any point in your code.

I have no experience with Codevision, but I can't imagine that performing a bitfield assignment that way would not be translated to the appropriate opcodes, the same way as if one were to perform a bitwise operation against the entire register in C.

answered Oct 30, 2013 at 22:12
\$\endgroup\$

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.