What should one expect when the following program runs on Arduino Uno?

void setup()
    DDRD |= 0b11;

void loop()
    PORTD |= 0b11;
    PORTD &= ~0b11;

When Serial.begin() is used, the pins PD0, PD1 might be configured as UART pins. After that if DDR is used, are the pins configured as GPIO, or are they still UART Rx, Tx pins?

  • what happens when you run the sketch?
    – jsotola
    Dec 27, 2018 at 17:16

1 Answer 1


As always, the answer is in the datasheet:

  • TXD/PCINT17 – Port D, Bit 1

TXD, Transmit Data (Data output pin for the USART). When the USART Transmitter is enabled, this pin is configured as an output regardless of the value of DDD1. PCINT17: Pin Change Interrupt source 17. The PD1 pin can serve as an external interrupt source.

  • RXD/PCINT16 – Port D, Bit 0

RXD, Receive Data (Data input pin for the USART). When the USART Receiver is enabled this pin is configured as an input regardless of the value of DDD0. When the USART forces this pin to be an input, the pull-up can still be controlled by the PORTD0 bit.

As to what trying to set the output level on the TX pin would have, only experimentation can show. It's not defined in the datasheet (because who would do it?)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.