Code: Select all
//This line of code is used in the stock example
//Adafruit_TLC59711 tlc = Adafruit_TLC59711(NUM_TLC59711, clock, data);
//Using this constructor, which uses the hardware SPI protocol, causes LEDs to flicker.
Adafruit_TLC59711 tlc = Adafruit_TLC59711(NUM_TLC59711);
Can someone help me understand why using the built-in SPI causes flickering? I'd like to use the built-in SPI because it's much faster (2 MHz vs. 70 kHZ).
Thanks for any advice you can offer.
Setup:
- I have 4 RGB LEDs connected to the board.
- Current limit resistor is 1.98k, which is a 25mA limit.
- Connections below (followed Adafruit tutorial http://learn.adafruit.com/tlc5947-tlc59 ... r-breakout
- DI -> Digital 11
- CI -> Digital 13
- VCC-> 3.3v
- GND -> GND
- V+ -> VIN
- No connections on Arduino pins 10 and 12 (SS and MISO).
- SPI is communicating at 2 MHz (clock divided by 8 )
- SPI mode 0 (default in SPI.cpp)
I scoped the SPI lines during a write and verified that the timing seems correct: This is what it looks like with the stock example method, which is essentially bit-banging pins 11 and 13 manually: Note that the configuration register is defined as follows:
OUT_TMG = 1, EXT_GCK = 0, TMG_RST = 1, DSP_RPT = 1, BLANK = 0 --> 10110b
(see page 21 of the datasheet for more info about these register bits.)
As far as I can tell, the hardware SPI transaction looks identical whether the TLC59711's output is enabled or not. I've tried changing the TMG_RST to 0, and I get the same result.
Has anyone seen this before?
Here is a link to the datasheet http://www.ti.com/lit/ds/symlink/tlc59711.pdf.
The important data concerning communication protocol is on page 12 (SDTI and SCKI signals).
And here is the entire TLC59711test sketch example, just for the sake of completeness:
Code: Select all
/***************************************************
This is an example for our Adafruit 12-channel PWM/LED driver
Pick one up today in the adafruit shop!
------> http://www.adafruit.com/products/
These drivers uses SPI to communicate, 2 pins are required to
interface: Data and Clock. The boards are chainable
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, all text above must be included in any redistribution
****************************************************/
#include "Adafruit_TLC59711.h"
#include <SPI.h>
// How many boards do you have chained?
#define NUM_TLC59711 1
#define data 11
#define clock 13
//Adafruit_TLC59711 tlc = Adafruit_TLC59711(NUM_TLC59711, clock, data);
Adafruit_TLC59711 tlc = Adafruit_TLC59711(NUM_TLC59711);
void setup() {
Serial.begin(9600);
Serial.println("TLC59711 test");
pinMode(10, OUTPUT);
tlc.begin();
tlc.write();
}
void loop() {
colorWipe(65535, 0, 0, 100); // "Red" (depending on your LED wiring)
delay(200);
colorWipe(0, 65535, 0, 100); // "Green" (depending on your LED wiring)
delay(200);
colorWipe(0, 0, 65535, 100); // "Blue" (depending on your LED wiring)
delay(200);
rainbowCycle(5);
}
// Fill the dots one after the other with a color
void colorWipe(uint16_t r, uint16_t g, uint16_t b, uint8_t wait) {
for(uint16_t i=0; i<8*NUM_TLC59711; i++) {
tlc.setLED(i, r, g, b);
tlc.write();
delay(wait);
}
}
// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
uint32_t i, j;
for(j=0; j<65535; j+=10) { // 1 cycle of all colors on wheel
for(i=0; i < 4*NUM_TLC59711; i++) {
Wheel(i, ((i * 65535 / (4*NUM_TLC59711)) + j) & 65535);
}
tlc.write();
delay(wait);
}
}
// Input a value 0 to 4095 to get a color value.
// The colours are a transition r - g - b - back to r.
void Wheel(uint8_t ledn, uint16_t WheelPos) {
if(WheelPos < 21845) {
tlc.setLED(ledn, 3*WheelPos, 65535 - 3*WheelPos, 0);
} else if(WheelPos < 43690) {
WheelPos -= 21845;
tlc.setLED(ledn, 65535 - 3*WheelPos, 0, 3*WheelPos);
} else {
WheelPos -= 43690;
tlc.setLED(ledn, 0, 3*WheelPos, 65535 - 3*WheelPos);
}
}