ELCouz
Newbie level 3
tlc5940
Dear members,
I'm currently trying to get the TI TLC5940 chip to work.
This is a project which consist of controlling 16 leds with independent pwm applied to each so I can apply many effects without using multiplexing.
This project is purely non-commercial.
I'm not asking to do the project , but i really need help on this particular chip because I'm really new when it comes to create drivers and timing strict related stuff. (i don't have access to a oscilloscope very often , neither a logic analyzer :S)
On my side I'm still searching...
Someone sent me a sample code to drive the TLC5940 but i don't know how to start with it.
Partial Code but he told me that this is what i need (it's for CCS C compiler):
oh btw, this is the partial code for this project > LINK
It's NOT mine !
The code that i have attached is for ATMEL AVR only :S.
The problems is that i never actually worked with the Atmel AVR platform , so many functions used in this code are unknown for me
[...]
I would like to create a function which is like set_pwm(pin,duty)
or even better ,, function to locate the right chip (because i know we can add a series of TLC5940)
This project would be highly beneficial to everyone , since this would be the first complete thread about the TLC5940. Once the entire project will be done, i will post the entire program to EDABoard including schematic(on demand) and how to use it.
Any idea?
I'm considering donating something to anyone that could successfully help me.
Anyone interested in a like-new EPIA motherboard 550mhz FANLESS ML-5000 for embedded project?
So in a brief summary:
-->The code must be converted to PIC18 platform (could be DsPIC too) using CCS C compiler . <--
Or if anyone have the source code of this driver. I'm willing to send the motherboard free of charge (freight included, unless you live in the Antarctica ) to you!
Thanks for reading this HUGE post
Have a nice day!
Best Regards,
Laurent
Dear members,
I'm currently trying to get the TI TLC5940 chip to work.
This is a project which consist of controlling 16 leds with independent pwm applied to each so I can apply many effects without using multiplexing.
This project is purely non-commercial.
I'm not asking to do the project , but i really need help on this particular chip because I'm really new when it comes to create drivers and timing strict related stuff. (i don't have access to a oscilloscope very often , neither a logic analyzer :S)
On my side I'm still searching...
Someone sent me a sample code to drive the TLC5940 but i don't know how to start with it.
Partial Code but he told me that this is what i need (it's for CCS C compiler):
oh btw, this is the partial code for this project > LINK
It's NOT mine !
Code:
#define unroll(bitidx) \
if (bit_test(data16,(bitidx))) PIC_SDO=1; \
else PIC_SDO= 0;\
SPI_CLK=1;\
SPI_CLK=0;
// send serial data for LED brightness into the 5940
#inline
void bitbang(uInt16 mux)
{
uInt8 j;
uInt16 data16;
uInt16* pTIdata16;
// mux is 0,1,2, and so is where to start our walk thru the TI data.
if (mux == 0)
pTIdata16= g_ti_data;
else if (mux == 1)
pTIdata16= g_ti_data_mux1;
else
pTIdata16= g_ti_data_mux2;
// 16 channels * 12 bits each = 192 bits going out
for (j=0; j<16; j++) // 16 channels per chip, ordered chan 15,
// 14, ... 0.
{
data16= *pTIdata16++;
// data16= 0;
// data16= 0x7FF; // 11 bits on
// data16= 0xFFF; // 12 bits on
unroll(11);
unroll(10);
unroll(9);
unroll(8);
unroll(7);
unroll(6);
unroll(5);
unroll(4);
unroll(3);
unroll(2);
unroll(1);
unroll(0);
if (kbhit(DMX_IN))
buffer_dmx_datain();
}
}
// ---------------------------------------------------------------------------
//timer-based interrupt to turn gsclk off and send 1 pulse to blank
// (actually it is a counter that generates interrupt on 16-bit overflow)
#INT_TIMER0
void restart_ti_pwm()
{
static uInt8 callcount= 0;
bool do_bitbang= FALSE;
static bool is_first_call= TRUE;
SET_PWM1_DUTY(0);
callcount++;
// should we do a mux?
if (callcount == 2) // 3 is a bit blinky when many are on at low levels
{
// yes
callcount=0;
unused_A3= 1;
// fets off now
MUX0= 0;
delay_cycles(1);
MUX1= 0;
delay_cycles(1);
MUX2= 0;
delay_cycles(1);
// Added Jan 2008: don't latch random data, to avoid brief flash
// at power-on.
if (is_first_call==FALSE)
{
// latch it
TI_XLAT= 1;
TI_XLAT= 0;
// do an extra clock after the dotcorrect data is loaded... page 15
// unsure what sdo should be. Leave it same as last bit loaded. It
// couldn't matter, else would be problems with cascaded devices.
if (g_doextraclock==1)
{
// setup_spi(SPI_SS_DISABLED);
SPI_CLK=1;
SPI_CLK=0;
g_doextraclock=0;
}
}
else
{
bitbang(g_muxcount);
is_first_call= FALSE;
}
// turn on the pfet for this cycle
if (g_muxcount==0)
MUX0=1;
else if (g_muxcount==1)
MUX1=1;
else
MUX2=1;
unused_A3= 0;
do_bitbang= TRUE;
}
// restart the pwm cycle
TI_BLANK=1;
TI_BLANK=0;
// get runnin' again
SET_TIMER0(TI_TIMER0_STARTVAL);
SET_PWM1_DUTY(1);
// output data for this new mux cycle (for next call in here)
if (do_bitbang)
{
// mux of 3, wrap?
g_muxcount++;
if (g_muxcount == 3)
g_muxcount= 0;
// loadup data for next mux cycle
bitbang(g_muxcount);
}
}
// ---------------------------------------------------------------------------
// see datasheet page 13
void init_ti_chips()
{
uInt8 i;
// dot correction data - all 100% on
TI_VPRG=1;
TI_XLAT=0;
PIC_SDO= 1;
delay_us(5);
for (i=0; i<96; i++) // 96 bits of 1 for 1 chip
{
SPI_CLK= 1;
SPI_CLK= 0;
}
TI_XLAT=1;
TI_XLAT=0;
TI_VPRG=0;
PIC_SDO= 0;
g_doextraclock=1;
}
// ---------------------------------------------------------------------------
main()
{
// clear, do the actual TI 16-bit data
for (temp8= 0; temp8 < 48; temp8++)
g_ti_data[temp8]= 0;
for (loopcount32=0; loopcount32 < SERBUF_SIZE; loopcount32++)
{
g_serialbuf_data[loopcount32]= 0;
g_serialbuf_rcsta[loopcount32]= 0;
}
// ----------------------------------
// setup timer for TI_BLANK clock, get counts as we gen GSCLKs
SETUP_TIMER_0(RTCC_EXT_L_TO_H | RTCC_DIV_2);
// PIC pwm to make the TI PWM gsclk, using timer2
SETUP_CCP1(CCP_PWM);
SETUP_TIMER_2(T2_DIV_BY_1,1,1);
// enable interrupts. want to get TIs running asap so they will be
// loaded with all-off data asap.
init_ti_chips();
SET_TIMER0(TI_TIMER0_STARTVAL);
ENABLE_INTERRUPTS(INT_TIMER0);
ENABLE_INTERRUPTS(INT_RDA); //serial
SET_PWM1_DUTY(1);
ENABLE_INTERRUPTS(GLOBAL);
// ----------------------------------
// main loop
return 0;
}
The code that i have attached is for ATMEL AVR only :S.
The problems is that i never actually worked with the Atmel AVR platform , so many functions used in this code are unknown for me
[...]
I would like to create a function which is like set_pwm(pin,duty)
or even better ,, function to locate the right chip (because i know we can add a series of TLC5940)
This project would be highly beneficial to everyone , since this would be the first complete thread about the TLC5940. Once the entire project will be done, i will post the entire program to EDABoard including schematic(on demand) and how to use it.
Any idea?
I'm considering donating something to anyone that could successfully help me.
Anyone interested in a like-new EPIA motherboard 550mhz FANLESS ML-5000 for embedded project?
So in a brief summary:
-->The code must be converted to PIC18 platform (could be DsPIC too) using CCS C compiler . <--
Or if anyone have the source code of this driver. I'm willing to send the motherboard free of charge (freight included, unless you live in the Antarctica ) to you!
Thanks for reading this HUGE post
Have a nice day!
Best Regards,
Laurent