SAMD21 mini board and Segger JLink EDU mini

Here is a small C program to blink two LEDs on the SAMD21 board used in this blog: https://larsenhenneberg.dk/2020/10/20/custom-samd21-bootloader-with-atmel-studio-7/  . The Segger Jlink EDU mini is used to flash the program directly to the SAMD21 board. In case the Segger software is not installed in the C:\Program Files (x86) folder, it can be downloaded and installed from: https://www.segger.com/downloads/jlink/  . After compiling the program below with Atmel Studio 7, an .bin output file is ready in the Debug folder of the Atmel Studio project.

/*
* SamD21_blink.c
*
* Created: 14-10-2020 12:27:43
* Author : Erik
* toogles the TX_LED and RX_LED
*/

#include <samd21.h>

void delay(int n)
{
int i;

for (;n >0; n–)
{
for (i=0;i<100;i++)
__asm(“nop”);
}
}

int main()
{
REG_PORT_DIR0 |= (1<<27); // TX_LED = PA27 as output
REG_PORT_DIR1 |= (1<<3); // RX_LED = PB03 as output
while (1)
{
REG_PORT_OUT0 &= ~(1<<27); // TX_LED = 0
REG_PORT_OUT1 |= (1<<3); // RX_LED = 1
delay(500);
REG_PORT_OUT0 |= (1<<27); // TX_LED = 1
REG_PORT_OUT1 &= ~(1<<3); // RX_LED = 0
delay(500);
}
}

At the Segger install folder , start the JFlashLite.exe program: