I have the (more or less) Leonardo-compatible board Olimexino-32u4. Both, the TX- and RX-LED are permanently on. To reduce power-consumption, I want to disable them by software. What is the reliable way to do it?
-
Examine the schematic and determine if they are wired to supplies, or to I/O pins. If supplies, desolder the associated resistors. If I/O pins, modify the bootloader and USB core to leave them off, or try issuing raw ATmega I/O access to turn them off if the are simply left on after the bootloader and not being constantly re-driven by USB traffic. – Chris Stratton Jul 24 '14 at 18:24
-
@ChrisStratton why not just desolder them in the first place? I don't know why it'd be bad to desolder the LED in the first place... – Anonymous Penguin Jul 24 '14 at 23:19
-
Just put a piece of tape over them... – DeveloperACE Jul 25 '14 at 00:07
-
5Software modifications are cheaper and easier to reverse. Tape doesn't save power. – Chris Stratton Jul 25 '14 at 01:52
-
How they are driven currently? The straight-forward way using digitalWrite(pin, LOW) does not work. pinMode(pin, INPUT) doesn't work either. – Thomas S. Jul 25 '14 at 06:18
3 Answers
Reading the answer from Gerben I realised the core of the issue: The TX/RX LED's on the Leonardo are wired PIN-LED-5V(common anode), whereas on the Olimexino-32U4 they are wired PIN-LED-GND(common cathode). So the two boards will need inverse signals for the same visual output.
Compare:
http://arduino.cc/en/uploads/Main/arduino-leonardo-schematic_3b.pdf
https://www.olimex.com/Products/Duino/AVR/OLIMEXINO-32U4/resources/OLIMEXINO-32U4_rev_A3.pdf
The most elegant solution will be to add a new board type (the code below is for IDE 1.0.x):
In your sketchbook create a folder 'hardware' and inside that 'olimexino'. In the olimexino folder create a file boards.txt with this content:
olimexino32u4.name=Olimexino-32U4 olimexino32u4.upload.protocol=avr109 olimexino32u4.upload.maximum_size=28672 olimexino32u4.upload.speed=57600 olimexino32u4.upload.disable_flushing=true olimexino32u4.bootloader.low_fuses=0xff olimexino32u4.bootloader.high_fuses=0xd8 olimexino32u4.bootloader.extended_fuses=0xcb olimexino32u4.bootloader.path=caterina olimexino32u4.bootloader.file=Caterina-Leonardo.hex olimexino32u4.bootloader.unlock_bits=0x3F olimexino32u4.bootloader.lock_bits=0x2F olimexino32u4.build.mcu=atmega32u4 olimexino32u4.build.f_cpu=16000000L olimexino32u4.build.vid=0x2341 olimexino32u4.build.pid=0x8036 olimexino32u4.build.core=arduino:arduino olimexino32u4.build.variant=olimexino32u4Create another folder 'variants' inside the olimexino folder.
- Inside that, create the folder 'olimexino32u4'.
- Now copy 'arduino/hardware/arduino/variants/leonardo/pins_arduino.h' to that folder
- Open the copy for editing - the path should be 'sketchbook/hardware/olimexino/variants/olimexino32u4/pins_arduino.h'.
Change the section that deals with TXLED and RXLED by swapping the macros that end in 1 with those that end in 0. It should look like this:
#define TX_RX_LED_INIT DDRD |= (1<<5), DDRB |= (1<<0) #define TXLED1 PORTD |= (1<<5) #define TXLED0 PORTD &= ~(1<<5) #define RXLED1 PORTB |= (1<<0) #define RXLED0 PORTB &= ~(1<<0)
I don't own the board so I can't test the solution. I hope that it solves your problem - just choose 'Olimexino-32U4' from the Tools->Board menu.
- 1,371
- 8
- 12
-
I've tried both values on TXLED and RXLED - one did not work. Only selecting the "Micro" board worked. – Thomas S. Jul 29 '14 at 09:58
-
This is the best solution. The problem stems from UART activity taking control of the Tx & Rx LEDs. Switching to the 'micro' board just reverses the states of these LEDs. By creating a custom pins_arduino.h board, and defining these macros to nothing will disable their use entirely by the UART, making them simple GPIOs. – Scott Jul 28 '22 at 20:29
Try adding this to your setup routine:
TXLED0;
RXLED0;
These macros (and their cousins TXLED1, RXLED1) are used to control the TX an RX LED's on Leonardo. They are defined in https://github.com/arduino/ArduinoCore-avr/blob/9f8d27f09f3bbd1da1374b5549a82bda55d45d44/variants/leonardo/pins_arduino.h#L95-L98
If that doesn't work you can try the solutions suggested here: http://forum.arduino.cc/index.php?topic=145262.0
- 113
- 3
- 1,371
- 8
- 12
-
1Switching the IDE to upload to "Micro" instead of "Leonardo" really solved the LED problem. – Thomas S. Jul 25 '14 at 16:10
-
See my new answer for more elaborate explanation and a maybe better solution. – user2973 Jul 25 '14 at 16:19
-
Alternatively: the pin mapping in the Arduino world is D17 for RX and D30 for TX, so instead of TXLED1 you can also use digitalWrite(30, HIGH). – volzo Jun 13 '17 at 18:51
The TXled is connected to physical pin 22, or PD5. RXled is connected to pin 8, or PB0. They are connected to the cathode of the led, so they have to be HIGH to turn off the leds.
To turn them HIGH use:
PORTD |= (1<<PORTD5);
PORTB |= (1<<PORTB0);
Not sure what the firmware does, and if it sets the leds back to low every once and a while. So in addition I would suggest also setting those pins to inputs.
DDRD &= ~(1<<DDD5);
DDRB &= ~(1<<DDB0);
- 11,286
- 3
- 20
- 34
-
The Olimexino-32u4 connect the LEDs to GND, but as written in my comment, this approach does not work. – Thomas S. Jul 25 '14 at 15:56