Main‎ > ‎electronics‎ > ‎

PIC24HJ12GP202 Control software for TLC5940

Well it has taken me not as long as I thought, it seems like ages, but when I look at the last time I wrote it was only a week ago, and I haven't done anything to the software for three days! So I'm actually quite happy with myself. I was a bit worried I'd struggle to even get it working and I admit there were moments when i almost lost hope, but two good late night sessions of coding on the weekend got me through! 

So now, i have functionally very similar software to what I was working on the atmega 1281 but it is running on the pic24gp202! In ways it is more complicated and more simple at the same time. One of the main advantages is that the TLC's per channel 12 bits of luminescence data now fits into a single intiger array member and the SPI has 16 bit mode so it takes 3 SPI sends to send 4 values instead of 3 sends to send 2. Yes each actual bit sending takes twice as long but it still works out quicker because each send has an overhead to account for. 

One of the interesting aspects is noting the similarities and differences between the AVR and the PIC, I must say that they are not as different as I thought.. I know people who "know" this kind of thing will say "well what did you expect"? But i'm a micro controller noob so I didn't really know what to expect! I suppose they are both in C, they both have ports and timers and interrupt routines, so what did i expect?? About the only difference I really noticed porting the code was output compare is a separate module in the PIC where it's just a function of the timer module in the AVR... So unless you are familiar with one or both, you probably don't even know what that means, in fact i'm a bit surprised that I know what that means! 

Ok, enough geek talk... The progress I made on the weekend has really spurred me on, I needed it a bit because i was starting to lose a little momentum. I think I really have to kick it up a notch and go for it. I've been questioning whether this is worth following through since the costs, both in money and time are quite substantial... 

I've bought several more of the components, including the 9 other TLCs i'll need. one thing that spurred me on is that farnell had a bunch in australia but someone bought them all, then they had 100 in singapore and over the weekend that went down to 85 and i thought if they run out and then they have a lead of a few months, that would suck! And ALSO they are now $5 on the farnell website, when I bought the 1st 3 they were closer to $8! considering i need 12 that's a bit difference!

So I don't really have any interesting photos unfortunately because I haven't really been doing much hardware wise... I will however post my working code which I scoured the internet for and I do not believe there is any working PIC code available out there. 


Usual disclaimer, use at your own risk, code is written by a rank amateur, poorly commented and substantially ripped off from acleone's great arduino tlc library available here http://code.google.com/p/tlc5940arduino/

Big thanks to him as I've even emailed him a few questions and he's been happy to help, so thank you very much.

One day I'll have to learn about the Creative Commons thing because that's cool..
You can of course click contact on the sidebar if you want to email me any questions or anything.