Pages: [1]   Go Down
Author Topic: Disabling internal pull-ups on Arduino Due.  (Read 1019 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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:
#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?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley
Logged

Pages: [1]   Go Up
Jump to: