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

Thread: Teensy 4 USB Midi not working - is it dead?

  1. #1
    Junior Member
    Join Date
    Apr 2020
    Posts
    5

    Teensy 4 USB Midi not working - is it dead?

    Hi,
    I have been building the wonderful MicroDexed project from Holger Wirtz (see: https://discourse.zynthian.org/t/mic...-to-go/1989/93). I have 3 Teensy 4.0 boards plus the compatible audio shields. All 3 were uploaded but only 2 of the units function - not a sound. I checked the midi input with Midi-Ox and discovered that only a small number of midi note on and note off messages are accepted by the usb/midi interface before it stops receiving any more. I then loaded a very simple sketch (below) to test the usb/midi function in and it always hangs after 3 pairs of note on/note off messages. I have tested serial in/out using the serial monitor and that works fine at 9600 baud. One other thing to note is that this particular teensy did not have the default led flashing sketch loaded but when I loaded it myself it worked fine. Is it broken?

    The midi test code is here:-

    #include <MIDI.h>

    // Simple tutorial on how to receive and send MIDI messages.
    // Here, when receiving any message on channel 4, the Arduino
    // will blink a led and play back a note for 1 second.

    MIDI_CREATE_DEFAULT_INSTANCE();

    static const unsigned ledPin = 13; // LED pin on Arduino Uno

    void setup()
    {
    pinMode(ledPin, OUTPUT);
    MIDI.begin(1); // Launch MIDI and listen to channel 4
    }

    void loop()
    {
    if (MIDI.read()) // If we have received a message
    {
    digitalWrite(ledPin, HIGH);
    //MIDI.sendNoteOn(42, 127, 1); // Send a Note (pitch 42, velo 127 on channel 1)
    delay(1000); // Wait for a second
    //MIDI.sendNoteOff(42, 0, 1); // Stop the note
    digitalWrite(ledPin, LOW);
    }
    }

    Can anyone help?

    Chris Swift

  2. #2
    Senior Member
    Join Date
    Apr 2020
    Location
    DFW area in Texas
    Posts
    115
    Chris:

    So that I don't make too many assumptions before I dive in head-first, did you make the following configuration choices in the Arduino IDE before initiating the build/download??

    --- Tools/Board: "Teensy 4.0"
    --- Tools/USB Type: "Serial + MIDI"

    It's probably fairly safe for me to assume that you did make the first configuration selection as indicated above, but can you please confirm how the second configuration item was set ??

    I'll try to help the best I can . . .

    Mark J Culross
    KD5RXT

  3. #3
    Senior Member oddson's Avatar
    Join Date
    Feb 2013
    Location
    Isle in the Salish Sea
    Posts
    1,351
    That's not USB midi code... you don't need the library MIDI.h but you need to compile as Mark indicates and the call the usbMIDI object to read and write according to this page: https://www.pjrc.com/teensy/td_midi.html

  4. #4
    Junior Member
    Join Date
    Apr 2020
    Posts
    5
    Hi, thanks for both responses. Yes, I did set the board type to Teensy 4.0 and the USB type to 'Serial + Midi' . I should point out that I flashed 2 other Teensy 4s at the same time with the same settings and the other 2 work fine. Thinking that this particular Teensy was sensitive to clock speed, I also reduced it to the lowest level but that did not help at all - still getting hangs after 3 pairs of note/on messages over usb/midi.

  5. #5
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Posts
    11,967
    Are the three Rev D audio boards soldered or socketed to the T_4.0's? If socketed would allow swapping to test.

    If soldered are all the joints good and clean? If T_4 soldered below - are all the tiny SMD's present in good shape?

    PJRC process puts Blink on during factory testing before packaging - which is well organized and assumed fool proof.

    Paul can confirm but without having passed the test leaving the Blink sketch in place I don't think it would work at all as the T_4 bootloader can't set up the MCU - though maybe TeensyLoader has an updated bootloader that would have allowed that - but only if the production installed bootloader chip is not a blank one needing programming as well during testing?

  6. #6
    Junior Member
    Join Date
    Apr 2020
    Posts
    5
    All 3 audio boards are socketed and I have swapped the 'faulty' teensy onto another board with a working teensy. This is very curious because, as I say factory blink was not working, but I did install an example blink sketch and that worked. Also a simple bidirectional serial test worked using the serial monitor. I am suspecting that one or more of the pins on the teensy that connects to the audio board is defective and causing the comms between the two boards to fail thus hanging the inbound usb/midi. Something I haven't tried is midi input via the RX1 port which is working fine on the other 2 boards. That might narrow down where the issue lies. I will report back.

  7. #7
    Junior Member
    Join Date
    Apr 2020
    Posts
    5
    OK, I have tried feeding midi in via RX1 and what I have discovered is that my setup partially works with this 'bad' teensy in that the attached LCD (via level converter) works and the 2 encoders are read and update the display. Also, data is read from the SD card on the audio board. But as soon as I enable a midi keyboard (via RX1 or USB), the teensy hangs and encoders are not read any more. Therefore, I conclude that the problem has to do with some of the pins used to communicate with the audio board. At this stage, I think I will just give up on this unit as I need to get on with my project with the other 2 teensys. I will probably be able to use this one for some other non-audio related project. Thanks all for your help.

Posting Permissions

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