Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: Serial port on Teensy 2.0 locks up after Tlc.update() ????

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Posts
    10

    Serial port on Teensy 2.0 locks up after Tlc.update() ????

    I have been running a set of TLC5940 chips on a Teensy 2.0. So far I've mainly been using an Mic and the FFT library to dynamically drive the tlc5940 outputs and it's been working great, but I've come across a bit of a hurdle when implementing some control via the USB serial.

    The problem occurs the first time Tlc.update() is called. As long as I don't communicate with the Tlc chips the serial will work just fine receiving and transmitting. The second a Tlc.update() is called the Teensy locks up (using realterm I can see that serial Tx pin gets locked up like it's stuck sending data).

    My assumption is that there is some pin being used for the Tlc library that is also used for the usb serial communication. I was pretty sure I read that the USB serial was pretty much isolated from the rest of the pins but maybe I'm incorrect. I've hunted around for information regarding any pins on the teensy that have to do with the usb serial and havent been able to find anything.

    If anyone has any other ideas on what would be causing this or any info about the usb serial and related pins I'd appreciate all the info I can get. Thanks!

  2. #2
    Junior Member
    Join Date
    Dec 2013
    Posts
    10
    Including the test sketch I'm using just to rule out any issues with the code.

    Code:
    //Test code for serial control of Tlc.5940 output.
    
    #include "Tlc5940.h"
    int channel[64];
    
    
    void setup()
    {
        Serial.begin(115200);
        Serial.println ("Setup complete. Starting Loop");
    };
    
    void loop()
    {
      //Wait for serial data
      if(Serial.available()>0)
      {
          //Convert recieved value 
           int serialChan = Serial.read()-48;
           Serial.print("I saw ");
           Serial.println(serialChan);
           Toggle(serialChan);  
      };
      
      //Temporary delay for debugging only. Remove when done!!
      delay(10);
    
    };
    
    
    //Toggle channel on TLC recieved from Serial
    void Toggle(int Chan)
    {
        if (channel[Chan] != 4095)
        {
          channel[Chan] = 4095;
        }
        else
        {
          channel[Chan]=0;
        };
        
        /*
          Commenting this line keeps the serial communication working fine. 
         If update is active teensy and serial port lock up completely.
        */
       // Tlc.update(); 
    
     
    };

  3. #3
    Junior Member
    Join Date
    Dec 2013
    Posts
    10
    O.K. interesting new 'symptom'. This may be completely unrelated but it seems to be to much of a coincidence.... I've been running the Teensy connected to the TLC's for 8+ hours a day for over a week. (they are controlling my christmas lights outside) and they have worked without a single problem. Right before I posted the problem with the serial port, I had loaded the exact sketch above to the teensy. I walked away after posting and returned about 10 minutes later to that smell that puts any diy'er into panic mode. (IC's melting). I starting sniffing everything in sight and tracked the smell down to the teensy's atmel chip

    The teensy light is stuck on, not recognized by the computer anymore, and appears to be completely toast. I'm ok with the teensy being fried (crap happens), but now I "need" to know what happened. The ONLY difference that has occurred between it's use the past week and the past 20 minutes is the change of sketches to the one above. The Tlc.update is commented out in the version that was on the teensy so I'm really baffled now as the teensy seemed to be acting fine and was not locking up when the update was commented out.

    Maybe it was pure coincidence and the board went out for some completely unrelated issue (I'm not quite ready to accept that right now), any one got any ideas??
    Last edited by jdc928; 12-21-2013 at 07:25 PM.

  4. #4
    Junior Member
    Join Date
    Dec 2013
    Posts
    10
    OK, first look at the end of this post for updated code with the correct additions like "Tlc.init();" and "Tlc.set();"

    Now... unfortunately I don't have another teensy 2.0 here at the moment so I had to pull out one of those gawd awful regular Arduino Uno boards

    With the code below I am able to get the desired results of controlling the Tlc5940 chip via serial commands. I don't know if I ever had the Tlc.init() function in the test code when I was using the teensy but even when I tried the faulty code with the uno I still didn't get any locking up so I'm hesitant to blame that on the issue I was having. I don't really have any further ideas as to why it wouldn't work on the teensy but I'm starting to feel like it's definitely related to the teensy board itself since the code is working on the uno.

    Code:
     
    //Test code for serial control of Tlc.5940 output.
    
    #include "Tlc5940.h"
    int channel[64];
    
    
    void setup()
    {
        Tlc.init();
        Serial.begin(115200);
        Serial.println ("Setup complete. Starting Loop");
      
    };
    
    void loop()
    {
      //Wait for serial data
      if(Serial.available()>0)
      {
          //Convert recieved value 
           int serialChan = Serial.read()-48;
           Serial.print("I saw ");
           Serial.println(serialChan);
           Toggle(serialChan);  
      };
      
      //Temporary delay for debugging only. Remove when done!!
      delay(10);
    
    };
    
    
    //Toggle channel on TLC recieved from Serial
    void Toggle(int Chan)
    {
        if (channel[Chan] != 4095)
        {
          channel[Chan] = 4095;
        }
        else
        {
          channel[Chan]=0;
        };
        Tlc.set(Chan,channel[Chan]);
        
        /*
          Commenting this line keeps the serial communication working fine. 
         If update is active teensy and serial port lock up completely.
        */
        Tlc.update(); 
    
     
    };

  5. #5
    Junior Member
    Join Date
    Dec 2013
    Posts
    10
    I know no one is really responding here, but I'm just posting any further findings here as record in case anyone else comes across this issue.

    Although using the basic sketch above did work, after setting up another sketch that update the full set of 64 channels i encountered a very similar issue on the uno as well. After the Tlc.update(); the channels did turn on but instantly I got a solid light on the TX and RX lights on the uno, the board apeared to freeze up and the com port locked up as well. Surely I am missing something in regards to the way the TLC library utilizes pins and it's relation to the main usb serial port. Time for more investigating.

  6. #6
    Junior Member
    Join Date
    Dec 2013
    Posts
    10
    Not sure what caused the freeze on the first Uno attempt but I think it was possibly just a code error where I had debugging lines spewing out. I ended up being able to drive the tlc5940 chips for hours last night via a data stream over serial. So I'm back to thinking this is definitely an issue specific to the teensy board. If anyone had any insight I'd love to put this uno back in the drawer where it belongs

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •