Pages: [1]   Go Down
Author Topic: pinMode sets OUTPUT pins high by default?  (Read 1389 times)
0 Members and 1 Guest are viewing this topic.
Brooklyn, NY
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I apologize if there's a straightforward explanation/workaround for this (I searched but couldn't find any).

On the Due + Arduino 1.5.1, if I designate any digital pin as OUTPUT, that pin will also be set HIGH.

ex.

void setup() {
  // put your setup code here, to run once:
  pinMode(25, OUTPUT); 
}

On 2 separate Dues, I set an LED + 100k resistor to pin 25, which lit up on initialize. When commenting out the above, the LED remained dark.

I also ran the same code on a Mega and Duo and saw the opposite result, i.e. the pin was kept LOW after the pinMode call and the LED remained dark.

Is there any documentation where this is explained that I missed?
Is there a way to set the default on initialize for Due OUTPUT pins to LOW??

Thanks!

Logged

European Union
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi

It happens to me too. If I put the instruction

pinMode(53, OUTPUT);

The pin 53 goes high. I have to put also the instruction digitalWrite(53, LOW); to init the pin 53 as output and low.

I'm going to read the datasheet of the AT91SAM3X8E because this is strange.

Bye
Logged

Brooklyn, NY
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Any word?

Too bad this isn't consistent with the AVR-based Arduino environment, but maybe there's an easy way to get the Due to set pins to LOW instead of HIGH on init?

Thanks!
Logged

Tasmania - Australia
Offline Offline
Sr. Member
****
Karma: 16
Posts: 322
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Reading the SAM3X main datasheet it says the following in section 32.5.1;
Quote
Pull-up Resistor Control
Each I/O line is designed with an embedded pull-up resistor. The pull-up resistor can be enabled
or disabled by writing respectively PIO_PUER (Pull-up Enable Register) and PIO_PUDR (Pull-up Disable Resistor).
Writing in these registers results in setting or clearing the corresponding bit in PIO_PUSR (Pull-up Status Register).
Reading a 1 in PIO_PUSR means the pull-up is disabled and reading a 0 means the pull-up is enabled.
Control of the pull-up resistor is possible regardless of the configuration of the I/O line.
After reset, all of the pull-ups are enabled, i.e. PIO_PUSR resets at the value 0x0.

Notice that it mentions all pull-ups are enabled after reset.
I wonder if maybe something has been overlooked in disabling pull-ups on setting pinMode(x, OUTPUT)?

cbeauvois wrote:
Quote
On 2 separate Dues, I set an LED + 100k resistor to pin 25, which lit up on initialize
I am surprised you were able to see any light emitting from the LED at all with a 100kΩ current limiting resistor, you must have exceptionally good eyesight ?

_____
Paul
« Last Edit: March 28, 2013, 12:50:03 am by rockwallaby » Logged


Brooklyn, NY
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

My bad, resistance was 1k; I confused this with the value of the internal (100k) pull-up.
Logged

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

See my post at http://forum.arduino.cc/index.php?topic=185230.0
Logged

Brooklyn, NY
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks, this was truly helpful smiley
Logged

Pages: [1]   Go Up
Jump to: