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?
Try adding this to your setup routine:
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
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.
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=olimexino32u4
Create 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.
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);