Pages: [1]   Go Down
Author Topic: Bug with LED's???  (Read 764 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I have an arduino due board. I was having issues and narrowed it down to the following code:

int led = 72;

// the setup routine runs once when you press reset:
void setup() {               
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);     
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(500);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(3000);               // wait for a second
}

The result of this code is a long flash with a short off period.
I thought perhaps there was a bug in digital write so I modified it to use the registers directly but still the same issue.

void loop() {
  REG_PIOC_SODR = 1 << 30;  // the set register appears to turn it off
  delay(500);               // wait for a second
  REG_PIOC_CODR = 1 << 30;  // the clear register turns it on
  delay(3000);               // wait for a second
  // the value of the REG_PIOC_OSDR is 0 here
}

The value of OSDR is correct and if it is enabled to be written to directly it has the same result.
Ie) writing a "0" appears to turn it on and "1" off

It is a minor problem but a little annoying.

I checked and it appears the TX LED does this aswell while the amber LED on pin 13 is normal.

Has anyone else come across this?

Stephen
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 549
Posts: 46142
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'd suggest that posting in the proper section of the forum would be more useful. There is a section dedicated to the DUE.
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 180
Posts: 8084
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You would get inverted blinking if you accidentally wired your LED between your output pin and +5V instead of between your output pin and Gnd.
« Last Edit: March 10, 2013, 04:25:38 pm by johnwasser » Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How to use this forum


Please edit your post, select the code, and put it between [code] ... [/code] tags.

You can do that by hitting the # button above the posting area.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

FWIW I agree with johnwasser.
Logged

SF Bay Area (USA)
Offline Offline
Tesla Member
***
Karma: 106
Posts: 6374
Strongly opinionated, but not official!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Pin 72 is the "RX" Led, right?  In fact, looking at the Due schematic, it is wired between VCC and the driver, rather than GND and the driver, which is "backward", and will indeed invert the "on" sense (LOW = ON, HIGH = OFF.)
This is pretty common; on many micros, you can get more current through the LED this way, just because of the way the physics of the output transistors works out (although that doesn't seem to be true of the SAM3X.)
It's not so much a bug, as an alternate way of implementing LEDs.

It's probably copied from the 8u2 hardware on the Uno, so that the usb code can be somewhat common.  It might have been copied there from the FTDI chip schematic.  It COULD reflect the original purpose - a "serial" signal state is HIGH when it's "idle"; it has transitions to low during actual data transmission.


* tmp.png (4.45 KB, 461x279 - viewed 12 times.)
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 452
Posts: 18694
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I wired an LED like that on my RS232 converter board, simply because RS232 is idle when high, and active when low, so by wiring it between the line and Vcc, it blinked when there was data.
Logged

Pages: [1]   Go Up
Jump to: