Teensy LC not rebooting after Platformio upload and power cycle, but works with Arduino IDE

  • I’ve uploaded the code with VS Code/Platformio
  • LED blinks as expected
  • After a power cycle (unplugging and plugging it back in) it is not blinking
  • after uploading it again it will work again as expected until I power cycle
  • it is working when the code is uploaded with Arduino IDE (also after a power cycle)

So why is the upload via platformio not power cycle “resistant”?

Has anyone an idea what is happening here?

Here is the code I’ve used:

platformio.ini

[env:teensylc]
platform = teensy
board = teensylc
framework = arduino
build_flags = -D USB_MIDI
lib_deps = Wire

main.cpp

#include <Arduino.h>
#include "led.h"
LED led;

void setup()
{
  led.begin();
}
void loop()
{
  led.an1();
  delay(1000);
  led.aus1();
  delay(1000);
}

led.cpp

#include "Arduino.h"
#include "led.h"

Adafruit_TLC59711 tlc = Adafruit_TLC59711(NUM_TLC59711, clock, data);

LED::LED()
{
}
void LED::an1()
{
    tlc.setLED(0, 30000, 30000, 0); // LED Number, Red, Green, Blue
    tlc.write();
}
void LED::aus1()
{
    tlc.setLED(0, 0, 0, 0); // LED Number, Red, Green, Blue
    tlc.write();
}
void LED::begin()
{
    tlc.begin();
    tlc.write();
}

led.h

#ifndef led_h
#define led_h
#include "Arduino.h"
#include <Adafruit_TLC59711.h>
#include <SPI.h>
#define data 10          // Data Pin 
#define clock 11         // Clock Pin
#define NUM_TLC59711 1 // How many boards do you have chained?

class LED
{
public:
    LED();
void an1();
void aus1();
void begin();

private:
};
#endif

Can you change that to -D USB_SERIAL_HID so that it creates a USB serial too, then add some Serial.println() in setup() and loop()? After a PlatformIO upload and power cycle, does it still open a USB serial, and print output?

@maxgerhardt Thanks for your answer

It getting weirder

  • Serial.begin and led.begin don’t work together
  • when I use both together, the teensy wont come back until I upload some sketch via the Arduino IDE
  • uploading with plaformio “recovers” the teensy sometimes but not alle the times

My guess would be, that something in the TLC59711 library is the problem here.
Strange though, that it works in the Arduino IDE, even the Serial.print and led simultaneously is working there…
I would really like to get this working in platformio, the Arduino IDE is quite cumbersome to use…
:thinking:

Problem solved. It works in Visual Micro.