teensy 4 stopped working with adafruit Tlc59711 library

Status
Not open for further replies.

vdgno

New member
Hi all.
I use Tlc59711 led drive to drive bi-color leds with teensy 4. I have uploaded default example sketch, changed clock and data pins to those, where my Tlc59711 is wired (clock 15 pin, data 14 pin). At start the library was working and the lights on leds appeared. However after some code manipulations this library stopped to work and my teensy started to disconnect from PC after my attempts to upload new sketch. Later, I returned to unedited default example code but teensy still doesn't work and IDE shows error:
"No Teensy boards were found on any USB ports of your computer.
Please press the PROGRAM MODE BUTTON on your Teensy to upload your sketch. An error occurred while uploading the sketch"
.
I disconnected teensy from periphery, also uploaded a blink sketch. Blink sketch loads successfully. However when trying to load a default adafruit Tlc59711 test sketch - the issue is still there, board is disconnecting right after second attempt of sketch uploading.
I tried this sketch example with spare teensy 3.2 - it uploads as usual. Is it possible that I have damaged a 4.0 board? Other sketches get there without a problems.

Code:
#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);
  
  increaseBrightness();
}


// 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);
  }
}

//All RGB Channels on full colour
//Cycles trough all brightness settings from 0 up to 127
void increaseBrightness(){
  for(uint16_t i=0; i<8*NUM_TLC59711; i++) {
      tlc.setLED(i, 65535, 65535, 65535);
  }
  for(int i = 0; i < 128; i++){
    tlc.simpleSetBrightness(i);
    tlc.write();
    delay(1000);
  }
}
 
If you have a program that is crashing, standard practice is to add print statements and delays to find out exactly where.
 
I cant figure out how serial.print can help me in this case. I found that critical line of code is tlc.write(), without this command sketch uploading fine
 
Status
Not open for further replies.
Back
Top