TLC59116 Confusion

neiltechspec

Senior Member
Trying to get a TLC59116 - i2c LED PWM driver to work.

I can't seem to understand the datasheet around device addressing.
Trying the code below, but doesn't work :-

Code:
	hi2csetup i2cmaster,$c0,i2cslow,i2cbyte 'set base address
	hi2cout $d0,($00,$01) 'enable LED all call address & turn on OSC
	hi2cout $d0,($02,$FF) 'LED 0 to max brightness
	hi2cout $d0,($03,$FF) 'LED 1 to max brightness
	hi2cout $d0,($04,$FF) 'LED 2 to max brightness
	hi2cout $d0,($05,$FF) 'LED 3 to max brightness
	hi2cout $d0,($06,$FF) 'LED 4 to max brightness
Any Help appreciated.

Tried to attach the datasheet PDF but it's too large.
Link to data sheet. http://www.ti.com/product/TLC59116/datasheet

Neil
 

Goeytex

Senior Member
The slave address of $C0 looks correct, but requires that A0-A3 be pulled low. So I assume that you have tied these pins to ground. Also it looks the reset pin should be pulled high vial a 10K resistor. Other than that I have little to offer except to study the datasheet, especially Section 10, Application information.
 

neiltechspec

Senior Member
Yep, A0-3 pulled low, Reset pulled high. + off course - pull ups on SDA & SCL.

It's actually mounted on a PCB with a dual Common Anode 7 Seg display.

I shall experiment further tomorrow.
 

Hemi345

Senior Member
try:
Code:
	hi2csetup i2cmaster,$c0,i2cslow,i2cbyte 'set base address
	hi2cout $00,($01) 'enable LED all call address & turn on OSC
	hi2cout $02,($FF) 'LED 0 to max brightness
	hi2cout $03,($FF) 'LED 1 to max brightness
	hi2cout $04,($FF) 'LED 2 to max brightness
	hi2cout $05,($FF) 'LED 3 to max brightness
	hi2cout $06,($FF) 'LED 4 to max brightness
 

neiltechspec

Senior Member
That doesn't work.

The base address is C0, but the data sheet is confusing to me for how commands are sent with either the 'LED all call' or sub addresses.
 

neiltechspec

Senior Member
A nights sleep & I've sussed it !.

Code:
	hi2csetup i2cmaster,$d0,i2cslow,i2cbyte 'default LED all call address 
	hi2cout $00,($08) 'enable sub address 1
	hi2csetup i2cmaster,$d2,i2cslow,i2cbyte 'sub address 1

	hi2cout $14,($ff) 'LED output state register 0
	hi2cout $15,($ff) 'LED output state register 1
	hi2cout $16,($ff) 'LED output state register 2
	hi2cout $17,($ff) 'LED output state register 3

	hi2cout $02,($ff) 'LED 0 full brightness
	hi2cout $03,($ff) 'LED 1 full brightness
	hi2cout $04,($ff) 'LED 2 full brightness
	hi2cout $05,($ff) 'LED 3 full brightness
	hi2cout $06,($ff) 'LED 4 full brightness
 

neiltechspec

Senior Member
D0 is enabled by default at power up, datasheet says not to use this for general I/O and to use a sub address.

Here's my working code for a 2 Digit Automotive Temp Display (just completed & tested it).

Code:
#rem
2 Dig Temperature Guage using TLC59116
Driving common anode twin 7 seg display
Uses DS18B20 as temp sensor

Version 1.0, January 2015


Right Digit
hi2cout $02,($XX)	'DP
hi2cout $03,($XX)	'C
hi2cout $04,($XX)	'D
hi2cout $05,($XX)	'E
hi2cout $0e,($XX)	'G
hi2cout $0f,($XX)	'F
hi2cout $10,($XX)	'A
hi2cout $11,($XX)	'B

Left Digit
hi2cout $06,($XX)	'DP
hi2cout $07,($XX)	'C
hi2cout $08,($XX)	'D
hi2cout $09,($XX)	'E
hi2cout $0a,($XX)	'G
hi2cout $0b,($XX)	'F
hi2cout $0c,($XX)	'A
hi2cout $0d,($XX)	'B

($00) is LED off, (&FF) is LED max brightness
I use ($7f) to reduce current & heat
  
    -A-
  |     |
  F     B 
  |     |
    -G-
  |     |
  E     C 
  |     |
    -D-  DP
    
    
BASEADDR 1100000X (C0)
LED ALL CALL  1101000X (D0) (enabled at power up)
SUB ADD 1     1101001X (D2)
SUB ADD 2     1101010X (D4)
SUB ADD 3     1101100X (D8)
X = R/W  1 read, 0 write

#endrem
  
#picaxe 08m2
#no_data
#terminal 4800

symbol temp = w0
symbol adjtemp = w1
symbol sensor = C.4

Init:
        pause 1000
	hi2csetup i2cmaster,$d0,i2cslow,i2cbyte	'LED all call address (datasheet says not to use this for general comms)
	hi2cout $00,($08)                                'enable OSC & sub address 1 ($d2)
        pause 100					        
	hi2csetup i2cmaster,$d2,i2cslow,i2cbyte	'sub address 1
	hi2cout $14,($ff)					'LED output driver 0 state enable (led 0-3)
	hi2cout $15,($ff)					'LED output driver 1 state enable (led 4-7)
	hi2cout $16,($ff)					'LED output driver 2 state enable (led 8-11)
	hi2cout $17,($ff)					'LED output driver 3 state enable (led 12-15)
	
Main:
	do
	readtemp12 sensor, temp
	if temp = 0 then gosub Fail
	if temp > 2048 then goto Negative
	adjtemp = temp * 10 / 16
  	bintoascii adjtemp,b23,b24,b25,b26,b27
  	
  	if b24 > 48 then hi2cout $02,($7f) hi2cout $06,($7f) endif	'if temp over 99 light up DP's
  	if b24 = 48 then hi2cout $02,($00) hi2cout $06,($00) endif

  	gosub Rdig
  	gosub Ldig
	sertxd (43,b24,b25,b26,".",b27,13,10)
	loop
	
Fail:	'display FF if sensor not responding
	do
	hi2cout $0c,($7f) hi2cout $0d,($00) hi2cout $07,($00) hi2cout $08,($00) hi2cout $09,($7f) hi2cout $0b,($7f) hi2cout $0a,($7f)
	hi2cout $10,($7f) hi2cout $11,($00) hi2cout $03,($00) hi2cout $04,($00) hi2cout $05,($7f) hi2cout $0f,($7f) hi2cout $0e,($7f)
	sertxd ("fail",13,10)
	pause 1000
	readtemp12 sensor, temp
	if temp <> 0 then
	 return
	endif 
	loop

Negative:	'if temp is below -9 display "- -"
	if temp >= 3195 then
	 hi2cout $0c,($00) hi2cout $0d,($00) hi2cout $07,($00) hi2cout $08,($00) hi2cout $09,($00) hi2cout $0b,($00) hi2cout $0a,($7f)
	 hi2cout $10,($00) hi2cout $11,($00) hi2cout $03,($00) hi2cout $04,($00) hi2cout $05,($00) hi2cout $0f,($00) hi2cout $0e,($7f)
	 sertxd("-9.9 or lower",13,10)
	 goto main
	endif

	'display temps down to -9
	
	let temp = - temp	   'two's compliment
	adjtemp = temp * 10 / 16
  	bintoascii adjtemp,b23,b24,b25,b26,b27
  	
  	'left digit -
  	hi2cout $0c,($00) hi2cout $0d,($00) hi2cout $07,($00) hi2cout $08,($00) hi2cout $09,($00) hi2cout $0b,($00) hi2cout $0a,($7f)
  	
  	'right digit  	
  	select case b26
	case 49 hi2cout $10,($00) hi2cout $11,($7f) hi2cout $03,($7f) hi2cout $04,($00) hi2cout $05,($00) hi2cout $0f,($00) hi2cout $0e,($00)
	case 50 hi2cout $10,($7f) hi2cout $11,($7f) hi2cout $03,($00) hi2cout $04,($7f) hi2cout $05,($7f) hi2cout $0f,($00) hi2cout $0e,($7f)
	case 51 hi2cout $10,($7f) hi2cout $11,($7f) hi2cout $03,($7f) hi2cout $04,($7f) hi2cout $05,($00) hi2cout $0f,($00) hi2cout $0e,($7f)
	case 52 hi2cout $10,($00) hi2cout $11,($7f) hi2cout $03,($7f) hi2cout $04,($00) hi2cout $05,($00) hi2cout $0f,($7f) hi2cout $0e,($7f)
	case 53 hi2cout $10,($7f) hi2cout $11,($00) hi2cout $03,($7f) hi2cout $04,($7f) hi2cout $05,($00) hi2cout $0f,($7f) hi2cout $0e,($7f)
	case 54 hi2cout $10,($7f) hi2cout $11,($00) hi2cout $03,($7f) hi2cout $04,($7f) hi2cout $05,($7f) hi2cout $0f,($7f) hi2cout $0e,($7f)
	case 55 hi2cout $10,($7f) hi2cout $11,($7f) hi2cout $03,($7f) hi2cout $04,($00) hi2cout $05,($00) hi2cout $0f,($00) hi2cout $0e,($00)
	case 56 hi2cout $10,($7f) hi2cout $11,($7f) hi2cout $03,($7f) hi2cout $04,($7f) hi2cout $05,($7f) hi2cout $0f,($7f) hi2cout $0e,($7f)
	case 57 hi2cout $10,($7f) hi2cout $11,($7f) hi2cout $03,($7f) hi2cout $04,($00) hi2cout $05,($00) hi2cout $0f,($7f) hi2cout $0e,($7f)
	case 48 hi2cout $10,($7f) hi2cout $11,($7f) hi2cout $03,($7f) hi2cout $04,($7f) hi2cout $05,($7f) hi2cout $0f,($7f) hi2cout $0e,($00)
	end select
	
	sertxd (45,b25,b26,".",b27,13,10)
	goto main
	
Rdig:	'right digit
	select case b26
	case 49 hi2cout $10,($00) hi2cout $11,($7f) hi2cout $03,($7f) hi2cout $04,($00) hi2cout $05,($00) hi2cout $0f,($00) hi2cout $0e,($00)
	case 50 hi2cout $10,($7f) hi2cout $11,($7f) hi2cout $03,($00) hi2cout $04,($7f) hi2cout $05,($7f) hi2cout $0f,($00) hi2cout $0e,($7f)
	case 51 hi2cout $10,($7f) hi2cout $11,($7f) hi2cout $03,($7f) hi2cout $04,($7f) hi2cout $05,($00) hi2cout $0f,($00) hi2cout $0e,($7f)
	case 52 hi2cout $10,($00) hi2cout $11,($7f) hi2cout $03,($7f) hi2cout $04,($00) hi2cout $05,($00) hi2cout $0f,($7f) hi2cout $0e,($7f)
	case 53 hi2cout $10,($7f) hi2cout $11,($00) hi2cout $03,($7f) hi2cout $04,($7f) hi2cout $05,($00) hi2cout $0f,($7f) hi2cout $0e,($7f)
	case 54 hi2cout $10,($7f) hi2cout $11,($00) hi2cout $03,($7f) hi2cout $04,($7f) hi2cout $05,($7f) hi2cout $0f,($7f) hi2cout $0e,($7f)
	case 55 hi2cout $10,($7f) hi2cout $11,($7f) hi2cout $03,($7f) hi2cout $04,($00) hi2cout $05,($00) hi2cout $0f,($00) hi2cout $0e,($00)
	case 56 hi2cout $10,($7f) hi2cout $11,($7f) hi2cout $03,($7f) hi2cout $04,($7f) hi2cout $05,($7f) hi2cout $0f,($7f) hi2cout $0e,($7f)
	case 57 hi2cout $10,($7f) hi2cout $11,($7f) hi2cout $03,($7f) hi2cout $04,($00) hi2cout $05,($00) hi2cout $0f,($7f) hi2cout $0e,($7f)
	case 48 hi2cout $10,($7f) hi2cout $11,($7f) hi2cout $03,($7f) hi2cout $04,($7f) hi2cout $05,($7f) hi2cout $0f,($7f) hi2cout $0e,($00)
	end select
	return

Ldig:	'left digit
	select case b25
	case 49 hi2cout $0c,($00) hi2cout $0d,($7f) hi2cout $07,($7f) hi2cout $08,($00) hi2cout $09,($00) hi2cout $0b,($00) hi2cout $0a,($00)
	case 50 hi2cout $0c,($7f) hi2cout $0d,($7f) hi2cout $07,($00) hi2cout $08,($7f) hi2cout $09,($7f) hi2cout $0b,($00) hi2cout $0a,($7f)
	case 51 hi2cout $0c,($7f) hi2cout $0d,($7f) hi2cout $07,($7f) hi2cout $08,($7f) hi2cout $09,($00) hi2cout $0b,($00) hi2cout $0a,($7f)
	case 52 hi2cout $0c,($00) hi2cout $0d,($7f) hi2cout $07,($7f) hi2cout $08,($00) hi2cout $09,($00) hi2cout $0b,($7f) hi2cout $0a,($7f)
	case 53 hi2cout $0c,($7f) hi2cout $0d,($00) hi2cout $07,($7f) hi2cout $08,($7f) hi2cout $09,($00) hi2cout $0b,($7f) hi2cout $0a,($7f)
	case 54 hi2cout $0c,($7f) hi2cout $0d,($00) hi2cout $07,($7f) hi2cout $08,($7f) hi2cout $09,($7f) hi2cout $0b,($7f) hi2cout $0a,($7f)
	case 55 hi2cout $0c,($7f) hi2cout $0d,($7f) hi2cout $07,($7f) hi2cout $08,($00) hi2cout $09,($00) hi2cout $0b,($00) hi2cout $0a,($00)
	case 56 hi2cout $0c,($7f) hi2cout $0d,($7f) hi2cout $07,($7f) hi2cout $08,($7f) hi2cout $09,($7f) hi2cout $0b,($7f) hi2cout $0a,($7f)
	case 57 hi2cout $0c,($7f) hi2cout $0d,($7f) hi2cout $07,($7f) hi2cout $08,($00) hi2cout $09,($00) hi2cout $0b,($7f) hi2cout $0a,($7f)
	case 48 hi2cout $0c,($7f) hi2cout $0d,($7f) hi2cout $07,($7f) hi2cout $08,($7f) hi2cout $09,($7f) hi2cout $0b,($7f) hi2cout $0a,($00)
	end select
	return
Neil.
 
Last edited:
Top