RobG 1,892 Posted July 26, 2013 Author Share Posted July 26, 2013 I would strongly suggest reading TLC5940 datasheet, so you understand how TLC5940 operates. updateTLC sends all data to shift register during PWM cycle. Then when PWM cycle is done, we latch this new data to GS registers. In short, updateTLC prepares data so we don't have any delay when PWM cycle is done. After we latch new data, we call updateTLC to send new data right away. Yes, SPI is 8 bit, but we TLC GS is 12 bit, so we send two 12 bit GS values at once and split them into three 8 bit bytes ( 2 x 12 = 3 x 8) Quote Link to post Share on other sites
sakshigoynar 0 Posted August 3, 2013 Share Posted August 3, 2013 hi RobG, what is the GS pwm cycle here? andand according to me updateTLC() should be called just after elese conditon and within the loop. becoz by executing the if or else condition, it shud put those leds element value in the buffer.and then when delay is encountered- it shud latch all data , and show the outputs.After executing ISR, it will again come back to while loop i.e. execute if or else conditon. Now new positions (according to the pattern), then it shud update in the UCB0TXBUF, and then call ISR....becoz now what is happening--->and when else or if condition is executed once,program control goes to delay_cycles and then interrrupt is called becoz of delay function as to calll ISR it need just a gap of 256us. From interrupt it goes to update TLC where updateTLC has no value for other leds .It has value for just two leds and it run for 8 times with no values of other "leds" array elements. Then what for, it runs for 8 times? In the interrupt, updateTLC is called , but when values in Quote Link to post Share on other sites
RobG 1,892 Posted August 4, 2013 Author Share Posted August 4, 2013 Which code/post# are you referring to? Quote Link to post Share on other sites
sakshigoynar 0 Posted August 4, 2013 Share Posted August 4, 2013 post # 1 and what is GS PWM cycle in the post # 3.? is it the while loop in the main? Quote Link to post Share on other sites
sakshigoynar 0 Posted August 4, 2013 Share Posted August 4, 2013 and what should be the programm flow(rough idea) if i want a breathing PWM on all 16 leds? Quote Link to post Share on other sites
RobG 1,892 Posted August 4, 2013 Author Share Posted August 4, 2013 There are two things that happen in the code from post #1 (after configuration steps.) 1. main loop with delay - this is where animation is taken care of, frame rate is set by the delay (not the prettiest solution but very clear.) 2. timer ISR - this is where data is sent to TLC when it should be Both are independent of each other. Animation is simple, delay - change data - delay - change data - ... TLC part - when all 4096 GS clocks have been sent (TLC's GS PWM cycle is done,) latch previously sent data, send new data, leave ISR (GS PWM cycles is already in progress.) GS PWM cycle is TLC5940's internal cycle (see datasheet) which takes 4096 GSCLK cycles. As for breathing LEDs, try this (this example uses linear curve, see other examples of breathing LEDs on 43oh for better curves) unsigned char cled; while (1) { _delay_cycles(500000); cled = 0; while ( cled < 16 ) { leds[cled] = counter; cled++; } if (direction) { counter--; if (counter == 0) direction = 0; } else { counter++; if (counter == 15) direction = 1; } } Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.