jbliesener
Well-known member
Hi, Paul!
I was trying to do a software reset on my T3. Back in the old Teensy 2 times, I used to call _restart_Teensyduino_() for that and it worked (as far as I remember). There was _reboot_Teensyduino_() to start the bootloader and _restart_Teensyduino() to reboot the current sketch.
For the T3 library, it seems that both functions are declared in hardware\teensy\cores\teensy3\core_pins.h, but only _reboot_Teensyduino_() seems to be implemented in usb_dev.c, issuing a "bkpt" instruction. _restart_Teensydiono_() gives me a linker error.
I just downloaded 1.20rc4, the problem persists.
What would be a safe way to reboot the processor? I believe that disabling interrupts and issuing something like "(*(void(*)())0)();" may not be sufficient, as this would not reset the internal hardware components. The other option would be to issue SYSRESETREQ through SCB_AIRCR, which requires some fiddling with the VECTKEY bits to make it work.
It would be nice if the function was either (implemented) or (not declared).
Thanks, Jorg
__EDIT__: This seems to work:
One of the posts here suggests that it might be a good idea to retain the remaining bits in SCB_AIRCR, but from what I see in the ARMv7 reference manual, it seems that there is only one additional bit group (PRIGROUP) that might be affected - and it is set to 000 on a reset. All others are either Write Only or Read Only, so I see no need to preserve them.
I was trying to do a software reset on my T3. Back in the old Teensy 2 times, I used to call _restart_Teensyduino_() for that and it worked (as far as I remember). There was _reboot_Teensyduino_() to start the bootloader and _restart_Teensyduino() to reboot the current sketch.
For the T3 library, it seems that both functions are declared in hardware\teensy\cores\teensy3\core_pins.h, but only _reboot_Teensyduino_() seems to be implemented in usb_dev.c, issuing a "bkpt" instruction. _restart_Teensydiono_() gives me a linker error.
I just downloaded 1.20rc4, the problem persists.
What would be a safe way to reboot the processor? I believe that disabling interrupts and issuing something like "(*(void(*)())0)();" may not be sufficient, as this would not reset the internal hardware components. The other option would be to issue SYSRESETREQ through SCB_AIRCR, which requires some fiddling with the VECTKEY bits to make it work.
It would be nice if the function was either (implemented) or (not declared).
Thanks, Jorg
__EDIT__: This seems to work:
Code:
#define AIRCR_VECTKEY 0x05FA0000
#define AIRCR_SYSRESETREQ 0x00000004
void _restart_Teensyduino_() {
SCB_AIRCR = (AIRCR_VECTKEY | AIRCR_SYSRESETREQ);
while(1);
}
One of the posts here suggests that it might be a good idea to retain the remaining bits in SCB_AIRCR, but from what I see in the ARMv7 reference manual, it seems that there is only one additional bit group (PRIGROUP) that might be affected - and it is set to 000 on a reset. All others are either Write Only or Read Only, so I see no need to preserve them.
Last edited: