Skip to content

Week04: Embedded programming

Group Assignment

demonstrate and compare the toolchains and development workflows for available embedded architectures

This group assignment document was written by Yuya Tokuyama.

Group Assignment Overview

We demonstrated and compared the tool chains and development workflows for the following embedded architectures.

Processor families Chip name in-system development Ref. Example
AVR ATmega328P ISP Arduino ISP ArduinoUno(ArduinoISP) > ATmega328P
ARM SAMD11C JTAG/SWD SAM D21 XiaoSAMD21(Daplink) > SAMD11Board
Xtensa ESP32 FTDI
USB-Serial
Barduino USBSerialCable > BrduinoBoard

What is a microcontroller board?

As the name suggests, a microcontroller board is a circuit board or device that has a microcontroller (microcomputer) installed on it. By writing a program created by the user into the microcontroller, it is possible to make it perform various operations. For example, it can display characters on a display, measure temperature, or communicate with the internet. In other words, a microcontroller board is a device that can realize the wishes of users who want to create a device with a certain function.

Installing the Arduino IDE

The official development environment for Arduino microcontroller boards is the Arduino IDE.

  • Open the Arduino IDE download page. https://www.arduino.cc/en/software

  • Download the Mac version of the Arduino IDE.

arduino_ide1.jpg

  • Install the Arduino IDE.

ArduinoUno AVR ATmega328P

The Arduino Uno is a popular microcontroller board used by a wide range of people, from beginners to experts. It is equipped with an ATmega328P microcontroller and can easily connect to many sensors and actuators.

Connection

We will use the Arduino Uno as an AVR ISP (in-system programmer) to write a program to another AVR microcontroller (the ATmega328P used in the Arduino Uno).

arduino_uno1.jpg arduino_uno1.jpg

Making Arduino UNO A Programmer

  • Select Arduino UNO from the Tools > Board menu in the Arduino IDE.

arduino_uno_isp1.jpg

  • Select Arduino UNO from the File > sample sketch menu in the Arduino IDE.

arduino_uno_isp2.jpg

  • Select “sketch > write to microcontroller board” in the Arduino IDE to write the code.

code

This is a program that alternately blinks two LEDs.

Blink.uno
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
const int LED_PIN1 = 12;
const int LED_PIN2 = 13;

// the setup function runs once when you press reset or power the board
void setup() {
    // initialize digital pin LED_BUILTIN as an output.
    pinMode(LED_PIN1, OUTPUT);
    pinMode(LED_PIN2, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
    digitalWrite(LED_PIN1, HIGH);
    delay(1000);
    digitalWrite(LED_PIN1, LOW);
    delay(1000);
    digitalWrite(LED_PIN2, HIGH);
    delay(2000);
    digitalWrite(LED_PIN2, LOW);
    delay(2000);
}

Use ArduinoUno ISP to write ATmega328P(ArduinoUno)

  • Select Arduino as ISP from the Tools > programmer menu in the Arduino IDE.

  • Select “sketch > Upload Using Programmer” in the Arduino IDE to upload the program. arduino_uno_isp3.jpg

Result

Barduino Xtensa ESP32

Barduino Xtensa ESP32 is a development board based on the ESP32 microcontroller. The ESP32 is a high-performance, multi-functional microcontroller that is equipped with the Xtensa LX6 dual-core processor.

Connection

Use the USBSerialCable to write programs to the Xtensa microcontroller (ESP32, which is used in Brduino).

arduino_uno1.jpg arduino_uno2.jpg

Arduino IDE settings

  • Select ‘Preferences’ from the Arduino IDE menu to open the Preferences window, and add https://dl.espressif.com/dl/package_esp32_index.json to the ‘Additional Board Manager URL’ field.

arduino_ide2.jpg

  • Select “Arduino ESP32 Boards” from the board manager and install it.

arduino_ide3.jpg

  • Set the following for writing.

arduino_ide4.jpg

  • Slide the “Programing Slider Switch” to the left in Programing mode.

arduino_ide5.jpg

code

This is a program that alternately blinks one LED.

Blink.uno
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
const int LED_PIN1 = 13;

// the setup function runs once when you press reset or power the board
void setup() {
    // initialize digital pin LED_BUILTIN as an output.
    pinMode(LED_PIN1, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
    digitalWrite(LED_PIN1, HIGH);
    delay(1000);
    digitalWrite(LED_PIN1, LOW);
    delay(2000);
}

Use the USBSerialCable to write programs to the ESP32(Barduino)

  • Select “sketch > Upload” in the Arduino IDE to upload the program.

arduino_ide6.jpg

Result

SAMD11Board ARM SAMD11C

The SAMD11C is a 32-bit ARM Cortex-M0+ microcontroller provided by Microchip Technology. This microcontroller is small, low-power, and high-performance, making it suitable for a wide range of applications.

Connection

To write a program to the SAMD11Board, install the DAPLink firmware on XiaoSAMD21 and connect them with a jumper wire. (The PC is connected for power supply only, not for data connection)

samd11board1.jpg

  • Download the DAPLink firmware from the Seeed Studio official wiki.

  • Press the reset button twice to put the Xiao SAMD21 into bootloader mode.

  • When you connect it to your PC, it will be recognized as an external drive.

  • Drag and drop the UF2 file you downloaded onto the external drive.

Arduino IDE settings

  • Select ‘Preferences’ from the Arduino IDE menu to open the Preferences window, and add https://files.seeedstudio.com/arduino/package_seeeduino_boards_index.json to the ‘Additional Board Manager URL’ field.

  • Select “Seeed SAMD Boards」” from the board manager and install it.

arduino_ide7.jpg

  • Download the Seeed_Arduino_DAPLink library and add it to the Arduino IDE.

  • Select the ZIP file you downloaded by going to “Sketch” > “Include Library” > “Install Library in ZIP Format”.

  • Open “File” > “Sketch Examples” > “Seeed_Arduino_DAPLink” > “simple_daplink” in the Arduino IDE, upload it to the Xiao SAMD21, and set the Xiao SAMD21 as a DAPLink device.

  • Connect Xiao SAMD21 to your computer, and in the Arduino IDE, select “Tools” > “Boards” > “Seeed SAMD Boards” > “Seeeduino XIAO”.

  • Connect the Xiao SAMD21 and SAMD11Board as follows.

Xiao SAMD21 SAMD11Board
3.3V 3.3V
GND GND
SWDIO SWDIO
SWCLK SWCLK
  • Select “Tools” > “Programmer” > “CMSIS-DAP”.

  • Select “Sketch” > “Program Bootloader” to write the bootloader to the SAMD11Board.

code

This is a program that alternately blinks two LEDs.

Blink.uno
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
const int LED_PIN1 = 13;

// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_PIN1, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_PIN1, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(1000);                      // wait for a second
  digitalWrite(LED_PIN1, LOW);   // turn the LED off by making the voltage LOW
  delay(1000);                      // wait for a second
}

Using SAMD11Board to write a program to ESP32 (Barduino)

  • Select “Sketch” and then “Upload” to write the program.

Result

Week 04 Group Work Completed. And on to the Individual Assignment…

Each person’s URL is listed