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

Thread: Controlling multiple Teensy3s from one PC

  1. #1

    Controlling multiple Teensy3s from one PC

    I'm building some hardware where I've got half a dozen teensy3s digitizing samples and doing some filtering, then shooting them out the USB (pseudo com port). Naturally, the COM port number changes each time you fire the system up, but that one I have figured out. I ask each Teensy to send me back the MAC, which is unique, so then I know the mapping between physical device and COM port. It seems to work ok with the 4 I've got sitting on my desk.

    BUT, how would I reprogram the device in-situ. I've done it by running multiple instances of the Arduino environment, but the teensy loader seems to get confused and it doesn't have a menu option for "com port". I've not thrashed systematically on this to figure it out. In any case, I'd like to be able to do it from the command line (so I can load all 6 as needed).

    Is it possible to do it without pushing the button? perhaps via some USB shenanigans. I could put a "command" in my little program that says "go to bootloader mode" I suppose, in which case what does that code need to look like. If that command fails and I brick it, then I will have to open it up and push the buttons, one by one. (or, in my case, jumper the appropriate pins on a connector where I brought the PROG and RESET lines out)

  2. #2
    Did you ever figure out a solution for this?
    This isn't necessarily the simplest solution, it would be nice if it could be done with just the loader, in a way that doesn't depend on the code running on the teensy, but...

    _reboot_Teensyduino_();
    will initiate a reboot.

    From: http://www.pjrc.com/teensy/jump_to_bootloader.html
    which is Teensy2 specific, it says you need to disable all interrupts, watchdog and any other peripherals, close the usb, and wait about 5ms, before doing this.
    I think the below is correct for the Teensy3:

    //disable watchdog
    WDOG_STCTRLH=0;
    //diable usb
    USB0_CTL=0;
    _delay_ms(5);

  3. #3
    Slight addendum, you will probably also want to comment out the following line in your makefile:
    # -$(abspath $(TOOLSPATH))/teensy_reboot
    this will present it from rebooting the teensy upon compile.

    Here is my full code from my project:

    //This is to let whatever is on the other end know to disconnect
    //in my case it is a windows PC over USB serial. If I leave it connected it sometimes seems to cause problems with the Teensy USB serial enumerating properly (perhaps because it is still in use)
    //so I send the string "DISCONNECT", flush the output, then give the pc 250ms to disconnect
    usb_serial_write("DISCONNECT",10);
    usb_serial_flush_output();
    _delay_ms(250);
    //in my case this closes the hardware serial, which i am using
    serial_end();

    //the reset should be suitably generic
    WDOG_STCTRLH=0;
    USB0_CTL=0;
    _delay_ms(5);
    _reboot_Teensyduino_();

Tags for this Thread

Posting Permissions

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