Go Down

Topic: Bug with LED's??? (Read 1 time) previous topic - next topic

da_steve101

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

PaulS

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

johnwasser

#2
Mar 10, 2013, 05:16 pm Last Edit: Mar 10, 2013, 10:25 pm by johnwasser Reason: 1
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.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Nick Gammon

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.

Nick Gammon

FWIW I agree with johnwasser.

Go Up