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

Thread: Is there a pin-conflict between USB-host and Serial1 on Teensy-3.6?

  1. #1

    Is there a pin-conflict between USB-host and Serial1 on Teensy-3.6?

    Hi,

    I was using Serial1 (pin 0,1) as MIDI input with a Teensy audio card and it worked nicely on my Teensy-3.6. Than I added a USB connector to the Teensy-3.6 (4(5) pins on the PCB). This does also work, but it seems that my (DIN-serial-)MIDI input is not working anymore... very strange. Is there a pin conflict or do I broke up something?

    TIA, Holger

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    6,758
    AFAIK they are independent - not seen any reason or note that they could conflict. They are independent parts of the processor.

    Any chance of a bridge to host GND pin or other in the soldering?

    Does the previously working code - with no USB Host lib/activity still fail? If the USB Host port is not activated or used and Serial1_Midi still fails - it would suggest the added pin connects are to blame.

  3. #3
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,153
    They are independent. I built this board some time ago to test Serial1-Serial5 together with USBHost_t36 MIDI and usbMIDI (to the PC). All are able to work simultaneously.

    Click image for larger version. 

Name:	midi.jpeg 
Views:	47 
Size:	152.9 KB 
ID:	13997

    You can find some of the test code in File > Examples > USBHost_t36 > MIDI > Interface_16x16.
    Last edited by PaulStoffregen; 06-12-2018 at 12:05 PM. Reason: typo

  4. #4
    Thanks @defragster and @PaulStoffregen,

    older code or code with disabled USBHost_t36 is also not working anymore... I will try to check with a scope at evening - perhaps also replacing the opto.

    Holger

  5. #5
    Ok, it seems that I have killed the serial input of pin 0 on my Teensy-3.6. Don't know how... very strange. My MIDI circuit is the one from https://www.pjrc.com/teensy/td_libs_MIDI.html and it worked for a long time. After connecting the USB-host port I got this problem. The PCB looks fine and I cannot imagine that I have made any shortcut while testing. I will try to use another serial port.

    BTW: The Teensy-3.5 has no USB-host port, am I right?

    Regards, Holger

  6. #6
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    6,758
    Correct - Only the T_3.6 has the Processor hardware for USB Host. The T_3.5 shares the same PCB - but 2 of those pins have alternate functions.

    Bummer on pin function loss. T_3.6 won't take much over 3.3V - did it get zapped?

  7. #7
    Quote Originally Posted by defragster View Post
    Correct - Only the T_3.6 has the Processor hardware for USB Host. The T_3.5 shares the same PCB - but 2 of those pins have alternate functions.
    Ah, ok, thanks!

    Quote Originally Posted by defragster View Post
    Bummer on pin function loss. T_3.6 won't take much over 3.3V - did it get zapped?
    Yes, it's a pitty. The really worse thing is, that it took much time to find the real problem. Only a comparison with my T_3.5 showed up that the input is broken. But this can happen during development... I have to learn to be more careful and to buy more spare parts - and there are some more serial ports on my T_3.6 I can break

    Regards, Holger

  8. #8
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    6,758
    The back of the T_3.5 versus the T_3.6 card details the function of those pin holes for alternate function. On the PCB the only diff { aside from MCU's label } is the added components for USB Host support on the T_3.6, that are empty on the T_3.5.

    If you buy one - it will leave you at a bad time … If you buy two or more - you'll never break one … working for me so far.

    Hopefully what ever broke that pin didn't do more damage that will show up later.

  9. #9
    Quote Originally Posted by defragster View Post
    Hopefully what ever broke that pin didn't do more damage that will show up later.
    Got my new T_3.6 and soldered the pin rows and USB port. My MicroDexed is working again :-)

    So I tried the same code on my old T_3.6: Serial is broken (also Serial2,3,4), USB or other things also seems to be broken. After getting some MIDI events via USB, the sound calculation stops - seems like a full stop of the T_3.6. That's the luck of a developer

    But I am glad that it works again on my new one!

    Regards, Holger

  10. #10
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    6,758
    … Good News … Bad News. Glad you are back in business.

  11. #11
    Bad news...

    The new T_3.6 worked 10 days ago (both inputs: MIDI and USB). After trying yesterday I have the same problems as with the broken one before: No input from MIDI, no input from USB. This is very strange because the same code works on the T_3.5 (with Serial-MIDI-Input) without problems.

    I really don't know what I am doing wrong. The (old) T_3.6 worked until I started to solder the external USB-Host-Interface. The same with the new one. First it runs but after some days it seems to be broken. Has anybody an idea what I am doing wrong?

    This is really bad. The T_3.[56] has such a friendly community, good support and a really good software stack, but for my project (MicroDexed) I cannot try with a new T_3.6 a week as long I don't know why I seem to kill the uC. I think I will give the ESP32 a try :-/

    Regards, Holger

  12. #12
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    6,758
    Can only guess without good photos of the solder situation. The Host USB has 5V near Pin 1.

    T_3.6 coming up on 2 years out? Not seen any reason to believe it would just fail without cause.

  13. #13
    Quote Originally Posted by defragster View Post
    Can only guess without good photos of the solder situation. The Host USB has 5V near Pin 1.

    T_3.6 coming up on 2 years out? Not seen any reason to believe it would just fail without cause.
    I will try to make photos the next days... I am sure that it is my fault, but do not have any idea what I have done wrong

  14. #14
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,153
    Very hard to guess what's going wrong here. It could be a simple hardware issue like a wire shorted between pins.

    But it could be a tough software problem which only looks like hardware failing. The simplest way to check is by loading a very basic test program onto the suspected-bad hardware. For example, something like this:

    Code:
    void setup() {
      Serial1.begin(9600);
    }
    void loop() {
      Serial1.println("Hello World");
      delay(100);
    }
    Then try to receive the data with a USB-serial cable or even another known-good Teensy running File > Examples > Teensy > USB_Serial > USBtoSerial.

    I see your project has a huge amount of code. A very common problem involves buffer overflows, where code writes beyond the end of an array. These often manifest in strange ways that look like flaky hardware failure, because the results depend on whatever happened to be placed in memory right after the array and how other code actually uses it.

    You're also using 2 interrupts which call queue_midi_event(). Are you sure queue_midi_event() is thread-safe to call from an interrupt? I see it does printing to Serial and calls a bunch of other code, which ultimately seems to access quite a bit of static data. This sort of code is almost never safe to use from interrupts, unless you design is very carefully with volatile variables and proper disable of interrupts when accessing shared data. I tried to explain these sorts of issues on the IntervalTimer page, where is says in red "Advanced programming is required".

    As a first step, I'd suggest using something like elapsedMillis which you check from your main loop to schedule stuff. Avoid interrupts. They make everything so much harder and almost always lead to very confusing bugs when used with anything but the simplest possible code.

  15. #15
    Hi Paul,

    many thanks for your quick response!

    Quote Originally Posted by PaulStoffregen View Post
    Very hard to guess what's going wrong here. It could be a simple hardware issue like a wire shorted between pins.

    But it could be a tough software problem which only looks like hardware failing. The simplest way to check is by loading a very basic test program onto the suspected-bad hardware. For example, something like this:

    Code:
    void setup() {
      Serial1.begin(9600);
    }
    void loop() {
      Serial1.println("Hello World");
      delay(100);
    }
    Then try to receive the data with a USB-serial cable or even another known-good Teensy running File > Examples > Teensy > USB_Serial > USBtoSerial.
    I tried some (own written) simple MIDI test programs and they failed on Serial and USB. But I will try again with a smaller program and a USB-serial-dongle.

    Quote Originally Posted by PaulStoffregen View Post
    I see your project has a huge amount of code. A very common problem involves buffer overflows, where code writes beyond the end of an array. These often manifest in strange ways that look like flaky hardware failure, because the results depend on whatever happened to be placed in memory right after the array and how other code actually uses it.
    The main code is running on some other systems (arm/i384/amd64) without problems. Only my "glue" code may be the source of pain...

    Quote Originally Posted by PaulStoffregen View Post
    You're also using 2 interrupts which call queue_midi_event(). Are you sure queue_midi_event() is thread-safe to call from an interrupt? I see it does printing to Serial and calls a bunch of other code, which ultimately seems to access quite a bit of static data. This sort of code is almost never safe to use from interrupts, unless you design is very carefully with volatile variables and proper disable of interrupts when accessing shared data. I tried to explain these sorts of issues on the
    IntervalTimer page, where is says in red "Advanced programming is required".

    As a first step, I'd suggest using something like elapsedMillis which you check from your main loop to schedule stuff. Avoid interrupts. They make everything so much harder and almost always lead to very confusing bugs when used with anything but the simplest possible code.
    If you mean the two IntervalTimers as interrupt sources: They are only used when starting the MIDI test events in a test function when I don't have a MIDI keyboard for generating events. Normaly I compile without #define TEST_NOTE, so the interrupts are not used.

    Why I am thinking it is a hardware problem: The same code (without using IntervalTimer) is running on the T_3.5 without problems... and it worked for about 10 minutes on a T_3.6 some days ago...

    Thanks again && regards, Holger

  16. #16

    Strange behaviour of Serial1 with MIDI interface T_3.6

    Hi all,

    I fixed some pieces of my code - especially I replaced the IntervalTimer with elapsedMillis (wow - there are so cool things inside Teensy ). I also soldered an additional 10K resistor between pin 7 and GND for my optocoupler (6N138) (as mentioned in https://www.pjrc.com/teensy/td_libs_MIDI.html).

    And I wrote a very simple serial test program and conected a USB-serial-adapter to Serial1 of my T_3.5 and both T_3.6:
    Code:
    void setup() {
      Serial1.begin(9600);
    
    }
    
    void loop() {
      if(Serial1.available())
      {
        Serial1.write(Serial1.read());
      }
    
    }
    It works for ALL three Teensys! I can see in minicom that my characters are echoed back. So the Serial1 must be working - even the one of the suspicious T_3.6. BUT the same MicroDexed code works only on the T_3.5 and the "newer" T_3.6 (so the newer T_3.6 is not broken as I thought before - and the old one seems also not to be broken).

    When Serial1 is working (and USB on both T_3.6) the MIDI circuit must have a problem or am I wrong? I used the circuit diagram from https://www.pjrc.com/teensy/td_libs_MIDI.html for the T_3.6 with a 6N138 and (as I wrote) I added a 10K resistor between pin 7 of the 6N138 and GND.

    That is really strange... I hope some of the senior members have an idea what's going wrong?

    Thanks, Holger

  17. #17
    Answering myself:
    Hmmmm, perhaps this thread helps?

    https://forum.pjrc.com/threads/27672...idi-Input-Woes

    There is the 470R replaced with a 220R resistor between Serial1 input and 3.3V...

    Regards, Holger

  18. #18
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    18,153
    Are you connecting a resistor to pin 7 on the optocoupler?

    The 6N138 ones I tested worked well with no resistor connected to pin 7. Some people say that resistor helps, but in some cases it can really interfere. Unless you know for sure they're needed, probably best to just leave 7 pin unconnected.

    Maybe try showing us photos of the circuitry you've actually built. Sometimes these things turn out to be a simple misunderstanding that none of us could anticipate until we see photos.

  19. #19
    Quote Originally Posted by PaulStoffregen View Post
    Are you connecting a resistor to pin 7 on the optocoupler?

    The 6N138 ones I tested worked well with no resistor connected to pin 7. Some people say that resistor helps, but in some cases it can really interfere. Unless you know for sure they're needed, probably best to just leave 7 pin unconnected.
    For now the additional resistor makes no difference. One T_3.6 works and the other not - with or without resistor on pin 7. I will desolder it.

    Quote Originally Posted by PaulStoffregen View Post
    Maybe try showing us photos of the circuitry you've actually built. Sometimes these things turn out to be a simple misunderstanding that none of us could anticipate until we see photos.
    Yes, of course - I just forgot...

    http://www.parasitstudio.de/MicroDex...719_072833.jpg
    http://www.parasitstudio.de/MicroDex...719_072857.jpg
    http://www.parasitstudio.de/MicroDex...719_072850.jpg
    http://www.parasitstudio.de/MicroDex...719_072933.jpg

    I think I will try to half the resistor towards pin 0 and try again.

    Thanks, Holger
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	IMG_20180719_072933.jpg 
Views:	9 
Size:	52.4 KB 
ID:	14234   Click image for larger version. 

Name:	IMG_20180719_072833.jpg 
Views:	9 
Size:	62.3 KB 
ID:	14235  


  20. #20
    Hi forum (Paul, defragster),

    I have desoldered the additional resistor (see above). I also replaced the 470R resistor for MIDI-IN with a 220R resistor: same result: One T_3.6 works (the newer one), the other not (even USB serial adapter works). This is really strange . I have no idea anymore how to fix this.

    Any ideas?

    Thanks && regards, Holger

Posting Permissions

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