Software Jump Bootlader, Teensy 3.1 (Or, use the DAC pin as a digital output?)

Status
Not open for further replies.

MuShoo

Well-known member
There may well be a simpler solution to this problem, but here goes. I need to be able to reboot a custom-board teensy 3.1 to the bootloader. On Teensy++ 2.0, I can just use _reboot_Teensyduino(), but that doesn't seem to work on 3.1 - all the forums threads I've come across seem to only discuss restarting a 3.1 from software, not jumping to the bootloader. So, I'm assuming there's no way to jump the bootloader chip purely from software running on the MK20DX256. With that in mind, I figured I could use another pin on the MK20, tie it to P5.2 on the MINI54, and just pull it low when I need to reboot. This works pretty well in rough testing with an official 3.1 board:

Code:
//using pin 32 as a 'reset' pin

void setup(){
   pinMode(13, OUTPUT);
   digitalWrite(13, HIGH);
   pinMode(32, OUTPUT);  
   digitalWrite(32, HIGH);

   delay(10000);
   digitalWrite(13, LOW);
   delay(500);
   digitalWrite(32, LOW);

   // 
}
//we should never get to the loop, if Teensy Loader is running

void loop(){}

This works surprisingly well, every 10.5 seconds, the teensy reboots and uploads new firmware if Teensy Loader is running.

The problem is, I'm all out of useable digital output pins on one of my processors on my custom board. All I have left is the DAC/A14 pin. I've got two custom-Teensy's living on the board communicating via Serial, so if necessary I can put the reset code for BOTH chips on a single MK20 (the main one would essentially send a reboot request via serial, and then the secondary MK20 would perform the actual reset) but that seems... ugly.

So, TL;DR: Is there a way to jump the MINI54 to upload mode, purely in software? If not, is it possible to use the DAC pin as a digital output (or an approximation of one) without using the audio library?
 
Answering my own question here....

the line 'analogWrite(A14, 0);' is sufficient to pull that pin down to VSS and jump the Mini54 to bootloader. Now to update my eagle library to hook that pin up! Still curious if there's any way to do this in software, though.
 
I used this some time back, but I cannot remember if it invokes the bootloader or just restarts the in-flash application
Code:
#define CPU_RESTART_ADDR (uint32_t *)0xE000ED0C
#define CPU_RESTART_VAL 0x5FA0004
#define CPU_RESTART (*CPU_RESTART_ADDR = CPU_RESTART_VAL);
 
Ah yes, I'd tried that one - just restarts the in-flash application (which is useful for another function I need, at least!)
 
Status
Not open for further replies.
Back
Top