Hi tolis81,
Here's some code that will programmatically place the board into bootloader mode after a system reset:
// Code to programmatically initiate bootloader mode after reset
#define BOOT_DOUBLE_TAP_ADDRESS (0x20007FFCul)
#define BOOT_DOUBLE_TAP_DATA (*((volatile uint32_t *) BOOT_DOUBLE_TAP_ADDRESS))
#define DOUBLE_TAP_MAGIC 0x07738135
void setup()
{
pinMode(LED_BUILTIN, OUTPUT); // Initialise the LED as an OUTPUT
}
void loop()
{
for (uint8_t i = 0; i < 5; i++) // Blink the built-in LED for 5 seconds before reset
{
digitalWrite(LED_BUILTIN, HIGH); // Turn LED on
delay(500); // Wait half a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(500); // Wait for a second
}
BOOT_DOUBLE_TAP_DATA = DOUBLE_TAP_MAGIC; // Start in bootloader mode after reset
NVIC_SystemReset(); // Reset the microcontroller
}