TLC59116 I2C Communications with PIC Coding Help

Thread Starter

Chardi

Joined Oct 3, 2015
28
Hi everyone,

I have jumped into another project regarding the TCL59116 to drive 10 LEDs since I finished designing a set of 10 band-pass filters (which I plan on merging these two together for a bigger project).
Right now, I simply want to have the code working for one LED output. After that, I can probably work my way from there.

I am using the PIC16F887 as I am relatively familiar with it thanks to a previous course at school.

My problem is that the LED is not lighting up despite my extensive research on the led driver as well as the steps to take in order to have it working.
Attached to this thread is my main code as well as a header file (which currently only has defined terms...functions will be moved in there eventually). My code is written with the information gathered from other forums and, of course, the datasheet.

If someone would be able to look over my code and point me towards my possible mistake(s), that'd be really helpful.

In case my coding isn't the problem, my connections should be fine, but we can never be so sure when troubleshooting right?
  • A0 - A3 are all grounded
  • REXT is near the recommended for 20mA LEDs (940 Ohms)
  • LEDs are of various forward voltage (1.8 - 3V)
  • Vcc is +5V and GND is indeed grounded
  • SDA and SCL are pulled HIGH with 4.7k resistors (and yes, they are not flipped)
Here's other things I know which might help you guys:
  • I have verified for ACKs and NACKs when communicating with the led driver through a logic analyzer as well as the data transmitted (everything seems fine)
  • Oscilloscope readings on the output pins of the TLC59116 show no AC signal (DC is either Vcc or Vcc - (LED forward voltage)
  • I'm hoping I did not accidentally fry the chip while soldering it onto my PCB converting it to a thru-hole component (or as I tested codes on it)
Thanks in advance for the help!
 

Attachments

geekoftheweek

Joined Oct 6, 2013
1,216
I'm not too familiar with C when it comes to PICs as I always use assembly... Does the I2C get set up as master, baud rate, and all that good stuff with the call to i2c_start()? Is there a check somewhere for an ACKnowledge from the slave after sending the address to make sure the slave responds? I didn't look at the datasheet, but know the PIC18 devices have a CCPR1L that needs to be set up as well as the PR2 for the PWM. As I've said before I don't have much knowledge of C when it comes to PICs so I may be overthinking things... as far as assembly goes those are some things that would be missing.
 

Thread Starter

Chardi

Joined Oct 3, 2015
28
@geekoftheweek
Nothing is missing for the i2c setup as most of it is done through the wizard in the compiler (hidden in the files such as <16F887.h>). CCPR1L and PR2 do sound familiar; however, they shouldn't be required any setup (although I did - CCP1CON and PSTR I believe, just to check the PWM of my microcontroller).

I checked with my logic analyzer and yes, the chip does "respond" to the ACKs, but there are no results from the chip.
 

geekoftheweek

Joined Oct 6, 2013
1,216
I guess I should have read your original post a little better... didn't see the parts about the ACKs and scope. As far as the PWM stuff goes... I should have read that better too!!
 

geekoftheweek

Joined Oct 6, 2013
1,216
Have you tried to read the registers to make sure the sent data is being used? I'm kind of suspecting the chip myself (but without seeing it for myself it's kind of a guess.) I peeked at the datasheet and would like to say thanks for introducing me... it's something that might work for a project sometime.
 

geekoftheweek

Joined Oct 6, 2013
1,216
The datasheet doesn't seem to give the best examples for reading... Based on normal I2C stuff I've worked with you would first write the address you want to read to the device. In this case you would send the control register data to the chip. You would then set a stop condition. Next you would restart your I2C and send the read address and then read the registers from the chip.

Just as an example...
i2c_start();
i2c_write(TLC59116);
i2c_write(reg_address);
i2c_stop();


i2c_start();
i2c_write(TLC59116 +1); // the read address is always the write address +1
input = i2c_read();
i2c_stop();

Someone more familiar with C may have a better answer for you in that department. That's just a guess.
 

geekoftheweek

Joined Oct 6, 2013
1,216
You've really peeked my interest... if you have a few minutes I could throw together a quick asm program to test this thing out. Since you have a way to see what's happening on the wires it won't take much effort.
 

geekoftheweek

Joined Oct 6, 2013
1,216
The only other thing I could think of... Did you try a value other than 0 for your write_analog? 255 (0xff) would be full bright and 0 would be full dim (I'm probably stating the obvious... but I had to ask!!) I'll be watching this one for a success story. I'm venturing a guess that this is part of a sound spectrum analyzer (if I've used the right terms)... something I've always wanted to put together.
 

Thread Starter

Chardi

Joined Oct 3, 2015
28
@geekoftheweek
Sure, but I don't know if I have the right programmer to use with an assembly file (I'm not familiar with how other compilers work).

And yes, I have already tried, and am currently troubleshooting with the analog value at 255 (0XFF).
Right now, I managed to get some results: The LEDs connected would slightly flicker when turning the power ON (I'm guessing a spike), but that means that the outputs are indeed sinking in current.

Yep! I'm planning on building an audio spectrum analyzer! Fancy :) It's due in about 36 hours so I'm doing my best to figure it out.
 

geekoftheweek

Joined Oct 6, 2013
1,216
I'm running out of ideas. I've stared at your program for some time now and as far as I can tell everything is in order. The only other thing I would suggest is to only write the PWM value once instead of constantly rewriting it in the while loop just to see what happens. I would think it shouldn't make a difference, but who knows... it may be finicky like that. I'm better at the programming than the electronics parts. You're probably having the kind of problem I would have that I usually sort out by sheer luck. Good luck to you and hopefully someone else comes along with some ideas!
 

Thread Starter

Chardi

Joined Oct 3, 2015
28
@geekoftheweek
Thanks! I've already tried omitting the while loop in vain...I'm triple checking my connections right now.

I'll definitely update this thread if I get it working!
 

Thread Starter

Chardi

Joined Oct 3, 2015
28
Thanks for the suggestion! Unfortunately it doesn't work. I'm guessing the chip is either fried, or I have a bad connection somewhere...
 
Top