Skip to content

Embedded programming

Group assignment requirements

The group assignment for this week is the following:
- Browse through the datasheet for your microcontroller
- Compare the performance and development workflows for other architectures
- Document your work to the group work page and reflect on your individual page what you learned

Microcontroller datasheet

The microcontroller being used is the Xiao [RP2040] which is a micro-sized dev board based on a [RP2040 by Raspberry PI] microcontroller. To find the specs I am referring to the dev board’s datasheet here, and the microcontroller datasheet here. By going through the datasheet for both the microcontroller and XIAO dev board I learned a lot about the microcontroller including the following:

picture of the XIAO pin layout

The Xiao contains the following pins:

[11] PWM pins
[11] general digital pins
[4] Analog pins
[1] I2C interface
[1] SPI Interface
[1] UART Interface

The XIAO dev board also contains the following components: [add # of buttons, LEDs, USB, and their functions]

[2] buttons (Reset and Boot)
[3] LED’s (User LED , Power LED, and RGB LED)
[Type-C] Power and downloding Interface
[3.3/5v] Power (5v Via USB-C), (3.3v For GPIO pins)

As for the microcontroller itself, we found the following information from the datasheet:

picture of the microcontroller pin layout

[16] PWM pins
[30] general digital pins
[4] Analog pins

And the following processor and memory information:

[Dual-Core, 32-bit ARM Cortex M0+ Processor] CPU
[Flexible clock, configurable max to 133MHz] Clock
[264KB] SRAM

screenshot of the system overview

According to the system overview we learned that it contains the following peripherals:

[2] I2C interface
[2] SPI Interface
[2] UART Interface

Architectures comparison

As part of this assignment, we compared the specs of all the microcontrollers we have in the lab.

XIAO RP2040 Arduino UNO ESP32
Bit size 32-bit 16-bit 32-bit
Max clock 133MHz 16MHz 240MHz
CPU/Family/Architecture ARM Cortex Dual core AVR Xtensa Dual core
Storage 264KB SRAM/2MB Flash memory 2KB SRAM/32KB Flash 512KB , 4 MB Flash
I/O pins 11 analog/digital, 4 PWM 14 digital, 6 analog, 6 PWM 28 digital, 12 Analog
operating voltage 3.3 volts 5v and 3.3v 3.3v
Connectivity I2C, SPI, UART I2C , SPI , UART Blutooth, WIFI, UART
Price 5.4$ 27.60$ 10$
source datasheet datasheet datasheet

By observation I can tell that ESP32 excell in clocking speed and storage compared to the others but unfortunately it consumes more power due to the conectivity options it have, But with this price it looks very great option.

Architectures development workflow

[ESP32]

This microcontroller can be programmed via [Arduino] which is based on [C]. I tried programming it to do a simple blink.

Also it can be programed Via (MicroPython) –> (Python) and some other versions of ESP32 like –> s3Devkit from Adafruit can be programed using (Circuit python)

Note : In addition to all of this Esp32 can run HTML, CSS, and Java Script.

[For ESP32 there is a special URL to download the board files from before we start trying the code.]

  • After opening Arduino IDE we have to go to files and then press on Preference

Preference

  • Then we need to paste the URL in the Additional board manager URL’s.

URL'S

LINK

https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

URL'S Link

  • Then we have to install the board from the Board Manager

Board Manager

ESP search and INSTALL

ESP 32 INSTALLED

  • Then we are ready to open the Blink Example from Arduino.

Blink Example

  • Then we will Only select the Board and the PORT.

ESP32 Board

  • After That we have to Select the port.

ESP32 Board

  • Then we are ready to upload the code.

Upload

  • Here we GO

[code]

  Blink

  Turns an LED on for one second, then off for one second, repeatedly.

  Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
  it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
  the correct LED pin independent of which board is used.
  If you want to know what pin the on-board LED is connected to on your Arduino
  model, check the Technical Specs of your board at:
  https://www.arduino.cc/en/Main/Products

  modified 8 May 2014
  by Scott Fitzgerald
  modified 2 Sep 2016
  by Arturo Guadalupi
  modified 8 Sep 2016
  by Colby Newman

  This example code is in the public domain.

  https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink
*/
// 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_BUILTIN, OUTPUT);
}

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

[The programing process is smooth but it require many steps to install the board files and also it require the user to press BOOT button in order to upload the code.] But However the process of uploading the code took (2.6 Sec) which is fast as it took (130 K-byte) space and in speed of (735.2 Kbit\sec)

[Arduino UNO]

This microcontroller can be programmed via [Arduino IDE] which is based on [C]. I tried programming it to do a simple blink.

  • We can Also use MicroPython which is based on Python to program Arduino UNO.

[For Arduino UNO its known that the process of uploading and dealing with code using Arduino IDE is quite smooth and fast specifically when it meant to use their own examples.]

  • We will use the same Blink Code we used previously and we will just change the board and the port if needed and simply upload the code.

Arduino Board

Arduino Port

  • Then we will press on Upload.

Arduino Port

  • It Works ^-^

[code]

  Blink

  Turns an LED on for one second, then off for one second, repeatedly.

  Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
  it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
  the correct LED pin independent of which board is used.
  If you want to know what pin the on-board LED is connected to on your Arduino
  model, check the Technical Specs of your board at:
  https://www.arduino.cc/en/Main/Products

  modified 8 May 2014
  by Scott Fitzgerald
  modified 2 Sep 2016
  by Arturo Guadalupi
  modified 8 Sep 2016
  by Colby Newman

  This example code is in the public domain.

  https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink
*/
// 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_BUILTIN, OUTPUT);
}

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

[The process is quite smoother than ESP32 (A lot smoother), the sketch took only 2% of the memory with (924 bytes) which is less by (129 K-bytes) from ESP32, and also the compiling process was fast and smooth compared to ESP32 which took almost 10 second to compile the code, and for the code to be uploaded it took a second almost which is less than what ESP32 took.]

I can tell that UNO is smoother and faster in terms of use when using Arduino IDE.

[Xiao RP2040]

This microcontroller can be programmed via [Arduino IDE] which is based on [C]. I tried programming it to do a simple blink

  • We can also program the XIAO RP2040 using microPython and CircuitPython.

[This Board also require a different URL to be installed from so we will go with the same process we done previously for the ESP32 and add the Xiao RO2040]

  • Adding the URL in the Additional Board Manager URL’s.

URL

LINK

https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json

  • Then we will open the board manager and Install the Board.

Board Manager

Install the Board

Board Installed

  • Now we will connect the board to the computer and choose the board and port from the Arduino IDE.

Choose the Board

Choose The port

  • Now we will Upload the code.

Code Uploaded

  • Here we go the User LED Blinks.

[code]

  Blink

  Turns an LED on for one second, then off for one second, repeatedly.

  Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
  it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
  the correct LED pin independent of which board is used.
  If you want to know what pin the on-board LED is connected to on your Arduino
  model, check the Technical Specs of your board at:
  https://www.arduino.cc/en/Main/Products

  modified 8 May 2014
  by Scott Fitzgerald
  modified 2 Sep 2016
  by Arturo Guadalupi
  modified 8 Sep 2016
  by Colby Newman

  This example code is in the public domain.

  https://www.arduino.cc/en/Tutorial/BuiltInExamples/Blink
*/
// 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_BUILTIN, OUTPUT);
}

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

[This time I can say the process is very smooth and easy it only require the board to be installed once which is the first time you use it and then you are good to go its much simple to use when uploading the code compared to ESP32 as it does not require the press of Boot every time you upload the code.] However the process of uploading is faster compared to the ESP32 but slower compare to the Arduino, Regarding the size this MCU took 52 K-byte compared to 924 byte the Arduino which is 51 K-byte more and 78 K-byte less compared with the ESP32.

Sources

The information referenced in this page was found in the following sources:
Source 1
Source 2
Source 3
Source 4