tako_chanz
Member
Hi All,
I used the simple code below with Teensy 2.0 for jumping to boot loader but it's not returning to user code. Seems it stuck at the boot loader and waiting for a firmware update?
What else is needed to make it continue from boot loader back to user code?
Thanks in advance,
Tako
I used the simple code below with Teensy 2.0 for jumping to boot loader but it's not returning to user code. Seems it stuck at the boot loader and waiting for a firmware update?
What else is needed to make it continue from boot loader back to user code?
Thanks in advance,
Tako
#include <avr/io.h>
#include <avr/interrupt.h>
#include <util/delay.h>
#include <PS2Keyboard.h>
const int ledPin = 11;
const int DataPin = 8;
const int IRQpin = 5;
PS2Keyboard keyboard;
void setup() {
pinMode(ledPin, OUTPUT);
delay(1000);
}
void bootloader_jump(void) {
cli();
// disable watchdog, if enabled
// disable all peripherals
UDCON = 1;
USBCON = (1<<FRZCLK); // disable USB
UCSR1B = 0;
_delay_ms(5);
EIMSK = 0; PCICR = 0; SPCR = 0; ACSR = 0; EECR = 0; ADCSRA = 0;
TIMSK0 = 0; TIMSK1 = 0; TIMSK3 = 0; TIMSK4 = 0; UCSR1B = 0; TWCR = 0;
DDRB = 0; DDRC = 0; DDRD = 0; DDRE = 0; DDRF = 0; TWCR = 0;
PORTB = 0; PORTC = 0; PORTD = 0; PORTE = 0; PORTF = 0;
asm volatile("jmp 0x7E00");
}
void loop() {
// digitalWrite(ledPin, HIGH); // set the LED on
// delay(500); // wait for a second
delay(10000);
bootloader_jump();
//_restart_Teensyduino_();
// digitalWrite(ledPin, LOW); // set the LED off
// delay(1000); // wait for a second
}