Go Down

Topic: Disabling internal pull-ups on Arduino Due. (Read 1 time) previous topic - next topic

morob05

Hi, i'm working on a project, but recently acquired an arduino due-board and want to make my code work with this board too. I had this little code-snippet to run in the setup function, to disable internal pull-ups which the wire library enables by default:

Code: [Select]
#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega8__) || defined(__AVR_ATmega328P__)
    // deactivates internal pull-up
    // atmega8 manual p. 167
    cbi(PORTC, 4);
    cbi(PORTC, 5);
  #else
    // deactivates internal pull-up
    // atmega128 manual p. 204
    cbi(PORTD, 0);
    cbi(PORTD, 1);
  #endif


cbi is defined:

Code: [Select]
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif


This used to work with the previous arduino-boards but it obviously doesn't work with the new Arduino Due which uses an ARM-chip instead of Atmega.

So i guess i can add something to that first code-snippet to make it work with the Arduino Due too, but i'm kind of lost what to put there? I googled "disabling internal pullup arduino due", but could not find an answer. Does someone have a quick code snippet, that disables internal pull-ups on the arduino due's SCL and SDA port?

vorkiej

Have a look in the PIO_PUDR (Pull Up Disable Register) page 666 datasheet of SAM3X. You should probably use something like this: REG_PIOB_PUDR = 0xFFFFFFFF (same for PIOA?).  Check also PIO_CODR (Clear Output Data Register), not sure if you have to set this also.

These also might be useful for you:
arduino-1.5.2\hardware\arduino\sam\system\libsam\source\pio.c
arduino-1.5.2\hardware\arduino\sam\system\libsam\include\pio.h
arduino-1.5.2\hardware\arduino\sam\sam\cores\arduino\wiring_digital.c


morob05

Hello. Thanks a lot for the reply. I ended up continuing to work on the project with the old arduino-board, but i will look into this now :)

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy