NOTICE: The Processors Wiki will End-of-Life in December of 2020. It is recommended to download any files or other content you may need that are hosted on The site is now set to read only.

LED usage on DVEVM

From Texas Instruments Wiki
Jump to: navigation, search

This article describes the usage of the 8 user controlled LEDs on DM6446 DVEVM.


On DM6446 DVEVM there are 8 user controllable LEDs available. These are controlled using I2C device PCF 8574A (I2C address 0x38).

See page 27 of TMS320DM6446 EVM schematic and section 2.4 (page 2-7) of Davinci-DM644x EVM Technical Reference.


In MontaVisata Linux kernel and recent git kernel device driver to control LEDs is located in


It controls four LEDs:

  • "red" -> DS1
  • "amber" -> DS2
  • "green" -> DS3
  • "blue" -> DS4

Note: Actually, all LEDs on DM6446 DVEVM are green :) But ARMs LED framework defines only these four colors. This seems to be the reason why only four of the 8 possible LEDs are controlled using this framework.

LED at DS8 is defined as "timer LED" and can be controlled by kernel configuration option CONFIG_LEDS_TIMER.

Note: CONFIG_LEDS_TIMER can only be set if CONFIG_GENERIC_CLOCKEVENTS is not set. Therefore this option isn't available in default DM6446 DVEVM git kernel configuration.


The 8 user controlled LEDs can be switched by user space software or by device drivers.

User space

From user space, you can control the four above LEDs via sysfs:

> echo claim > /sys/devices/system/leds/leds0/event
> echo green on > /sys/devices/system/leds/leds0/event
> echo red on > /sys/devices/system/leds/leds0/event
> echo red off > /sys/devices/system/leds/leds0/event
> echo amber on > /sys/devices/system/leds/leds0/event
> echo blue on > /sys/devices/system/leds/leds0/event
> echo release > /sys/devices/system/leds/leds0/event

Note: the release turns off the LED's!

Example program

* Eric Tanner 2007.
* Simple program to blink the LEDs on the DaVinci
* EVM using the the LED port expander PCF8574A at I2C Slave Address 0x38.
* I2C Support and I2C device interface must be turned on in the kernel. 

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <signal.h>
#define I2C_DEVICE      "/dev/i2c/0"
#define I2C_DEV_ADDR    0x38
#define I2C_SLAVE       0x0703

int main()
       int i2c_fd;
       int state = 0;
       unsigned char val = 0x00;
       int ret;

       struct timespec req = {
               .tv_sec = 0,
               .tv_nsec = 100000000,

       if((i2c_fd = open(I2C_DEVICE,O_RDWR)) < 0) {
               printf("Unable to open the i2c port!\n");

       if(ioctl(i2c_fd, I2C_SLAVE, I2C_DEV_ADDR)== -1) {
               close( i2c_fd );
               printf("Unable to setup the i2c port!\n");

       do {
               val <<= 1;
               val |= 0x01;
               if(val == 0xFF)
                       val = 0xFE;
               write( i2c_fd, &val, 1);

        } while (!nanosleep (&req, NULL));

       close ( i2c_fd );
       printf ("End.\n");
       return 0;

Device drivers

Device drivers can use function call



#include <asm/leds.h>