Purpose of RX and TX LEDs?

Unlike on the AVR-based boards, these LEDs do not seem to flash when uploading code, nor do they flash when using Serial1, for I/O.

Wayne

not flashing when uploading code via the "Arduino Zero (Programming Port)" or via the "Arduino Zero (Native USB Port)" ?

Dirk67:
not flashing when uploading code via the "Arduino Zero (Programming Port)" or via the "Arduino Zero (Native USB Port)" ?

The LEDs don't flash for either port. As far as I can see, the LEDs are just are just mapped to two I/O pins.

Wayne

yeah, you are right,
I would have expected, that at least the SAM-BA bootloader on the SAMD21 would use these LED's (mapped to two I/O pins) when uploading code via the "Arduino Zero (Native USB Port)" ... (?)

Yes RX/TX led are not implemented yet.

I've opened an issue for that:

What pins are the LEDs on? You could probably use them for whatever you want.

Here the definitions

// LEDs
#define PIN_LED_13           (13u)
#define PIN_LED_RXL          (25u)
#define PIN_LED_TXL          (26u)
#define PIN_LED              PIN_LED_13
#define PIN_LED2             PIN_LED_RXL
#define PIN_LED3             PIN_LED_TXL
#define LED_BUILTIN          PIN_LED_13

BTW I'm already doing a patch to use them to signal serial activity on SerialUSB and once implemented there will be no way to use them from the sketch (or at least to use them together with SerialUSB).

Hi, Is now RX/TX led supported ?

cmaglie:
Here the definitions

// LEDs

#define PIN_LED_13          (13u)
#define PIN_LED_RXL          (25u)
#define PIN_LED_TXL          (26u)
#define PIN_LED              PIN_LED_13
#define PIN_LED2            PIN_LED_RXL
#define PIN_LED3            PIN_LED_TXL
#define LED_BUILTIN          PIN_LED_13




BTW I'm already doing a patch to use them to signal serial activity on SerialUSB and once implemented there will be no way to use them from the sketch (or at least to use them together with SerialUSB).

I can't see this patch as being a positive thing. I'd much prefer to be able to use these pins in any way I like, since serial activity indicators aren't that useful to me. If using SerialUSB (and by extension some of the other pluggable USB messages) will preclude the use of two hardware pins, that's a big loss to users wishing to create their own boards using the SAMD21. I'm using my Zero as a prototype platform before committing to a hardware design, and I'd love to be able to use some of the "reserved" pins such as RXLED and TXLED.

I can't see this patch as being a positive thing. I'd much prefer to be able to use these pins in any way I like, since serial activity indicators aren't that useful to me. If using SerialUSB (and by extension some of the other pluggable USB messages) will preclude the use of two hardware pins, that's a big loss to users wishing to create their own boards using the SAMD21. I'm using my Zero as a prototype platform before committing to a hardware design, and I'd love to be able to use some of the "reserved" pins such as RXLED and TXLED.

I totally agree.

The Tx and Rx LEDs can be turned on and off directly using the port registers:

To set the Tx LED pin to an output (PORT_PA27):

REG_PORT_DIRSET0 = PORT_PA27;

To switch the Tx LED on:

REG_PORT_OUTCLR0 = PORT_PA27;    // digitalWrite(PIN_LED_TX, LOW);

To switch the Tx LED off:

REG_PORT_OUTSET0 = PORT_PA27;    // digitalWrite(PIN_LED_TX, HIGH);

To set the Rx LED pin to an output (PORT_PB03):

REG_PORT_DIRSET1 = PORT_PB03;

To switch the Rx LED on:

REG_PORT_OUTCLR1 = PORT_PB03;    // digitalWrite(PIN_LED_RX, LOW);

To switch the Rx LED off:

REG_PORT_OUTSET1 = PORT_PB03;    // digitalWrite(PIN_LED_RX, HIGH);

The SAMD21 sinks current from the LEDs, so CLR switches the LED on and SET turns it off.

These pins are defined in the variant files, you can simply use this :

pinMode(PIN_LED_RXL,OUTPUT/INPUT/INPUT_PULLUP);
pinMode(PIN_LED_TXL,OUTPUT/INPUT/INPUT_PULLUP);

digitalWrite(PIN_LED_RXL,LOW/HIGH);
digitalWrite(PIN_LED_TXL,LOW/HIGH);

Where PIN_LED_RXL and PIN_LED_TXL is defined like this :

#define PIN_LED_RXL          (25u)
#define PIN_LED_TXL          (26u)

I attempted to write a very simple sketch to blink the three on-board LEDs on a Zero.

EXPECTED

Time L Tx Rx
0 sec
1 sec ON
2 sec
3 sec ON
4 sec
5 sec ON
6 sec
7 sec ON
8 sec
9 sec ON

ACTUAL

Time L Tx Rx
0 sec
1 sec ON
2 sec ON
3 sec ON ON
4 sec ON
5 sec ON ON
6 sec
7 sec ON
8 sec ON
9 sec ON ON

The problem with the actual results is that the L LED stays on when it shouldn't.

Can anyone figure out what’s happening here? Thanks.

Here is my code:

/*============================================ 
  Blink the three on-board LEDs in sequence
============================================*/

#include "Arduino.h"
#define LED_CNT  3    // number of on-board LEDs:

// define an array of the on-board LEDs:
int ledPin[] = {
  PIN_LED,            // labeled "L" on the board:
  PIN_LED3,           // labeled "TX" on the board:
  PIN_LED2            // labeled "RX" on the board:
};

int led = 0;

void setup() {
  // initialize each pin as an output:
  for (int i = 0; i < LED_CNT; i++)
    pinMode( ledPin[ i ], OUTPUT );
}

void loop() {
  // clear all LEDs:
  for (int i = 0; i < LED_CNT; i++)
    digitalWrite( ledPin[ led ], LOW  );

  // blink the selected LED:
  delay(1000);
  digitalWrite( ledPin[ led ], HIGH );
  delay(1000);

  // choose next LED:
  led += 1;
  if ( led >= LED_CNT ) led = 0;
}

At first I thought my problem was that the "L" LED illuminates whenever "Tx" or "Rx" illuminate. But I made an ever so minor modification to my sketch and got a different blinking response, without that proposed "L" to "Tx/RX" link.

I have a similar problem. I have a green LED on my board tied to the TX LED. Whenever there is SerialUSB.print line on my code the LED will blink. Also this LED will sometimes stay on when it shouldn't. Even if I do digitalWrite (LOW), it still stay on.

Is there a way to unlink SerialUSB.print from turning on and off the TX LED?

Hi solar82,

On some boards such as the Arduino Zero the pins sink current from (rather than source current to) its TX and RX LEDS. This results in inverted logic, so that setting digitalWrite() to LOW will turn the LED on, while setting it to HIGH will turn the LED off.

Is there a way to unlink SerialUSB.print from turning on and off the TX LED?

Yes, but it requires editing the Arduino Zero's core file: "variant.h" and commenting out references to PIN_LED_TXL and PIN_LED_RXL:

// LEDs
#define PIN_LED_13           (13u)
//#define PIN_LED_RXL          (25u)
//#define PIN_LED_TXL          (26u)
#define PIN_LED              PIN_LED_13
#define PIN_LED2             PIN_LED_RXL
#define PIN_LED3             PIN_LED_TXL
#define LED_BUILTIN          PIN_LED_13

Any subsequent board updates from Arduino will overwrite any changes to this file.