TLC5940 on the Photon

I’ve been trying to get a series of TLC5940 chips working on the Photon.

I used this github as a start point to try and get this working on the photon.

I’ve had some level of success, and I think I’ve got it set up correctly for the STM32F2 chip on the photon. I’m by no means an embedded programmer, and am quite new to this form of coding.

So right now, I have 3 TLC5940’s connected in series using the SOUT to SIN linkage. If I set all bits to low, and update, it will blank it perfectly. If I set all bits high, it will get most of the way through the LED’s, but a random number of the last LED’s will either not light up, or will be at a different intensities (i.e. the SIN data isn’t going through correctly).

I was thinking that it might be due to the xlat signal being passed at the wrong time, but i’m struggling to think how I can get an interrupt to go before the blank pulse.

Has any one else got any ideas here? I’ve been contemplating building my own SPI library so I know exactly what is being set and when, but that feels like the completely wrong path to go down. It all looks like it’s a problem clocking in the data, as it looks like some bits are off. I’ve got a scope coming soon which I hope will give me a bit more clarity on the timing, and what is sent when.

My code is here: https://github.com/nzchicken/photon-tlc5940

Happy to accept pull requests, etc.

Thank you very much for this, I’ll be sure to give it a spin.

I’ve been trying to get my photon to work with the TLC for weeks, although it has mostly been trial and error, because I’m not really into embedded programming. (yet)

That being said, would you be able to point me to some resources on how to get started on the needed functionalities (SPI, GPIO, …). Once I get the hand of it I’ll be happy to help.

cheers

I’ve been puzzling over this for the last month ish.

The chip that actually does the work in the photon is a STM32F205.

The photon only exposes a set list of pins from the STM32F2. The Photon datasheet that gives you that info is here: https://docs.particle.io/datasheets/photon-datasheet/ (the pinout section is the interesting part - especially the STM32 pin part)

The datasheet is useful to figuring out what pins actually do what, and what is available on what pin (i.e. the clock pins are only available on certain pins, etc) http://www.st.com/web/en/resource/technical/document/datasheet/CD00237391.pdf

As for the GPIO/timer init structure stuff, I managed to harvest a bit from the tutorials on this guys site to figure out how to do stuff: http://visualgdb.com/tutorials/arm/stm32/pwm/

One thing I’ve struggled to find is a good reference for the STM32F2XX C code structure. There is a bunch of info on STM32 chips, but sometimes the init structure stuff is different. I ended up looking through the photon source stuff on the particle github to find the header files for the STM32F2 chip, which gives some info on what does what. https://github.com/spark/firmware/tree/develop/hal/src/photon/wiced/platform/MCU/STM32F2xx/peripherals/libraries/inc

I’m about 95% sure that i’ve gone down the wrong path, and that there is some leveraged Particle library that can be used to set this up, without having to define the actual structure myself. But it’s difficult to tell. I see something about this HUP interface around, but I still don’t really understand it.

I can possibly add more comments to the code to give you more understanding of the init structure I’ve used. Some of it is guessing on my part of course.

And one last thing, the SIN/SCK pins need to be mapped to A5 and A3 respectively (SPI_MOSI, and SPI_SCLK) for my library to work. I just realised that this isn’t mentioned in the code anywhere, and expects people to know where the SPI pin outs are.

Thanks! :slight_smile:
I’ll be sure to look into this. If I come up with anything useful I’ll submit a PR.

I know this is old, but wonder if anyone got this working?I have a bunch of these chips and wouldn’t mind being able to use them on the Photon!

Unfortunately not. I ended up going for RGB lights that had the inbuilt drivers WS2081 I think they’re called.

It would really be nice to get this working however, as this would allow the control of a whole heap of servo’s off one chip. I might do some more investigation at some point, however it just became too hard to troubleshoot. The speed of the requests was too fast for the average osciliscope I have, so it’s hard to figure out where I was going wrong.

Please feel free to fork and/or PR on the library that I have on my github though :smile:

@nzchicken there is a library for servo’s; i would like it for the PWM outputs in general.