Page 1 of 1

USB pins: INPUT or OUTPUT?

Posted: Tue Nov 15, 2011 12:11 am
by TheDude
Hi all,

Code: Select all

DDRD = ~(1 << 2);   /* all outputs except PD2 = INT0 */
DDRB = ~USBMASK;    /* set all pins as outputs except USB */

form the PowerSwitch example project
so USB is input


Code: Select all

DDRD = 7;    /* 0000 0111 bin: all pins input except USB (-> USB reset) */

from HIDKeys example project
so USB is output

what now, input or output?
:?:


thx

Re: USB pins: INPUT or OUTPUT?

Posted: Tue Nov 15, 2011 2:41 pm
by Daid
Both. The USB pins are bi-directional. I think the USB code configures them anyhow, for bi-directional ports you need to change both the DDR and PORT register.