Skip to main content

AN-1098 Using GreenPAK’s I2C Port to Control an RGB LED’s Color



For related documents and software, please visit:

Download our free GreenPAK Designer software [1] to open the .gp file [2] and use the GreenPAK development tools [3] to freeze the design into your own customized IC in a matter of minutes.

Dialog Semiconductor provides a complete library of application notes [4] featuring design examples as well as explanations of features and blocks within the Dialog IC.

  1. GreenPAK Designer Software, Software Download, and User Guide, Dialog Semiconductor
  2. AN-1098 Using GreenPAK's I2C Port to Control an RGB LED's, GreenPAK Design File, Dialog Semiconductor
  3. GreenPAK Development Tools, GreenPAK Development Tools Webpage, Dialog Semiconductor
  4. GreenPAK Application Notes, GreenPAK Application Notes Webpage, Dialog Semiconductor
  5. SLG46531 Datasheet, Dialog Semiconductor

Authors: Chuck Husted and Luke Thomas


This app note explains how to reconfigure the SLG46531’s registers via I2C. Specifically, it shows how to change the registers associated with counters that set the PWM values for driving the R, G, and B cathodes of an LED.

It is important to note that any reconfigurations via I2C are volatile and will revert to the programmed code after POR inside the GreenPAK resets.

Figure 1. GreenPAK Used as an RGB Driver in a Larger System

GreenPAK Benefits

GreenPAK is a very versatile, low current consumption IC. It can offload functions from other microcontrollers and larger SOC’s. For example, a microcontroller can be active (drawing several mA of current), and can write via I2C to the SLG46531V to set the RGB, then the microcontroller can go into deep sleep mode to save system current. The GreenPAK would manage the RGB light function and wake up the microcontroller as needed. The GreenPAK can also act as an interrupt by using another I/O pin.

GreenPAK Configuration

The GreenPAK design shown in Figure 2(a) implements a simple RGB LED driver. On the GreenPAK Universal Dev Board, connect Pin 3 to the cathode of the blue LED, Pin 5 to the cathode of the green LED and Pin 7 to the cathode of the red LED. The common anode should be connected to the VDD pin of the GreenPAK.

Figure 2(a). GreenPAK block diagram with counters for setting the PWM of each color
Figure 2(b). GreenPAK emulator window

Remember to use current limiting resistors in series with the LEDs as needed. Counter0 was set to a 100 Hz refresh rate so that flicker is not visible to the naked eye. Counter2 has a register that can be set from 0 to 255 which represent 255 PWM steps. Each step represents 0.39%. CNT2, 3, and 4 control the PWM for the RGB LED.

Creating an I2C Command to Write Register Bits

This application note will not cover the basic GPAK I2C command format. Instead, we will emphasize the specific commands to implement the RGB LED. In the example GreenPAK design file (found on the Dialog website) we have used a default chip address of 00 (decimal) which we will show in hex format as 0x00. Note [ represents an I2C start bit and ] represents a stop bit.

Since the design uses four counters we need to know the address of each counter’s register.

Table 1. Counter register address


Byte Address (Hex)









Table 1 provides the register address for each of the four counters used in this design. Changing these registers will impact the brightness of the three LEDs and the final color.

Since counters 2 through 4 range from 0 to 255 (decimal), we can write to them via I2C with data from 0x00 to 0xFF.

By putting together all of this information, we can create a command to turn off the red LED by writing the following to the GreenPAK to turn off the red LED:

[ 0x00 0xC0 0x00 ]

Similarly, this would turn off the green LED:

[ 0x00 0xC1 0x00 ]

And this command would turn off the blue LED:

[ 0x00 0xC2 0x00 ]

To turn on all three LEDs to full brightness (and a PWM signal of 100% for each) we can simplify the write command since the three register addresses are sequential:

[ 0x00 0xC0 0xFF 0xFF 0xFF ]

This command writes a 100% PWM signal to the counter associated with the red LED first, then 100% to the counter for the green LED, and lastly 100% to the counter for the blue LED.

Using the GreenPAK Development Kit Emulator

We can use the GreenPAK Development kits emulator to create the signals that we need to drive the LEDs properly. First we must connect the development kit to a computer or laptop’s USB port. Second, place a SLG46531V IC into the socket. Third, open the design file inside the GreenPAK Designer software and click the Emulator button in the upper toolbar. This should appear as in Figure 2(b). Next we must enable the I2C tools within the software. This is the button to the right side of the screen. Please see Figure 2(c).

After enabling the I2C tools, we must select the I2C Virtual Inputs button. This tool allows us to write directly to the counter registers. Please see Figure 3(a).

Enter the value of 256 (decimal) into the “New Value” box for counter 0 (CNT0). This sets the refresh timing for the PWM’s. Next enter 255 into the “New Value” box for Counter 2 (CNT2) and press the “Write” button.

Figure 2(c). GreenPAK emulator window in Emulation Mode
Figure 3(a). GreenPAK emulator with I2C Virtual Inputs window

This will turn on the red LED with a 100% PWM setting.

See Figure 3(b) for the window settings and Figure 3(c) for a picture of the development kit connected to an RGB LED.

Next enter 0 into the “New Value” box for CNT2 and enter 255 into the “New Value” box for CNT3. Press “Write” and you will see the green LED turn on at 100% PWM.

Please see Figure 3(d) for the window settings for the green LED and Figure 3(e) for a picture of the green LED on.

Likewise for the blue LED at 100% PWM, please see Figure 3(f) for the window settings and Figure 3(g) for a picture.

To simplify the write process for changing the PWM setting for all three colors at the same time, you simply use a sequential write command.

Figure 3(b). GreenPAK I2C Virtual Inputs for 100% PWM setting for red LED
Figure 3(c). GreenPAK Development Kit driving the red LED in an RGB LED

For example, to write 50% PWM to all three LEDs this would be the command:

[ 0x00 0xC0 0x80 0x80 0x80 ]

This command starts by writing 0x80 to the register for the red LED PWM, immediately followed by writing 0x80 to the register for the green LED PWM and finally writing 0x80 to the register for the blue LED PWM.

Figure 3(d). GreenPAK I2C Virtual Inputs for 100% PWM setting for green LED
Figure 3(e). GreenPAK Development Kit driving the green LED in an RGB LED
Figure 3(f). GreenPAK I2C Virtual Inputs for 100% PWM setting for blue LED
Figure 3(g). GreenPAK Development Kit driving the blue LED in an RGB LED


We can use a GreenPAK SLG46531V to implement RGB LED driver functions. By implementing a system architecture this way, a microcontroller or other system SOC can be put in sleep mode to save overall system power consumption which is desirable for battery based portable and wearable systems.