0
\$\begingroup\$

Can anyone just verify quickly for me that this:

cbi(PORTD, 0);
cbi(PORTD, 1);

will disable the internal pullups on the AT90USB1286? I'm trying to avoid damaging some 3.3V components that I'm communicating w/over i2c. Thanks in advance.

\$\endgroup\$
0
\$\begingroup\$

First of all, the cbi/sbi(PORT,PIN) macros are deprecated. I advice using

PORT &= ~(1<<PIN);   //Clear
PORT |= (1<<PIN);    //Set

The AT90USB128 datasheet states that:

If PORTxn is written logic one when the pin is configured as an input pin, the pull-up resistor is activated. To switch the pull-up resistor off, PORTxn has to be written logic zero or the pin has to be configured as an output pin. The port pins are tri-stated when reset condition becomes active, even if no clocks are running.

So, if the pins are configured as inputs, your command will disable the internal pull-ups.

Having said that, your setup will most likely not work unless your 3.3V devices are 5V-tolerant. I would recommend using a simple bi-directional level shifter, explained in the popular NXP/Philips appnote found here. It only requires one N-ch FET and two pull-up resistors per bus line.

Alternatively, if you have access to the 3.3V power supply you could use this to power the MCU by cutting the connection between VBUS and UVCC/AVCC/VCC (datasheet Fig. 21-5).

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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