Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC with TI TLC5940 (Will give an EPIA ML5000 ($100 val.))

Status
Not open for further replies.

ELCouz

Newbie level 3
Joined
Feb 6, 2008
Messages
4
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,281
Activity points
1,322
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 !

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 :p) to you!

Thanks for reading this HUGE post :D

Have a nice day!

Best Regards,
Laurent
 

tlc5940 pic

I am not sure what your question is the attached code appears to be pretty complete did you compile and run it? What problems are you running into?
 

tlc5940 project

The problem is the code attached is for Atmel AVR (and the one i've posted in the topic is for CCS C but it's partial :( ),,, I need to be able to compile it with the CCS C compiler which is for Microchip PIC. this is a totally different architecture.

Yet many people who work with both of them may help me to convert it easily.

(Hint) The tiRGBLED module from rgbled.org use this chip with a PIC and I think their drivers are for Hi-Tech C compiler. However, i don't know if it's free or not. I will ask them.

I hope this help.

Laurent
 

tlc5940 schematic

You can try to implement the code for PIC, just read the data sheet , i waiting 15 pcs of tlc5940 ... i planning to run them with arduino /avr board/ but i see in forums:
1.3 pwm channels to control the TLC.
2.for programming the eeprom in TLC /dot correction/ you will need Vprg 22V :)) cool.
3.some calculation for Iref /current limitation/
i will post the result with arduino
p.s. before i use 89s52 but AVR is better :)

about the PIC i don't like it becouse there is to much customization of chip

REGARDS FROM BULGARIA
 

pic tlc5940

i have some code to interface a tlc5944 with a dspic30f6012a in ccs but i haven´t tested it yet. anyone have possibility to test it fo me?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top