---
title: Embedded programming. Group 2 Work. 
summary: Group work. Comparing microcontrollers.
show_authors: true
authors:
    - name: Akseli Uunila
      url: http://fabacademy.org/2023/labs/oulu/students/akseli-uunila/
    - name: Abhishek Kumar
      url: http://fabacademy.org/2023/labs/oulu/students/abhishek-kumar/
    - name: Aarne Pohjonen
      url: https://fabacademy.org/2023/labs/oulu/students/aarne-pohjonen/
---

# Group work for week 4

In this group assignment, we learned about different tools for embedded programming.

We used three different microcontrollers all in the Seeed XIAO form factor.
We first learned putting simple sample codes to those
and later used the "ring oscillator" codes and measured the signal frequencies.

## Programming the microcontrollers

We first load the program into microcontrollers. We used programs given by our instructor. Detailed steps of this process could be found in **our individual documentation** for this week
as each one of us did one microcontroller.

We used these "ring oscillator" codes from Neil:

* [RP2040 code](https://pub.pages.cba.mit.edu/ring/GPIO/RP2040/ring.RP2040.ino)

* [ESP32C3 code](https://pub.pages.cba.mit.edu/ring/GPIO/ESP32/ring.ESP32C3.ino)

* [SAMD21 code](https://pub.pages.cba.mit.edu/ring/GPIO/SAMD11C/ring.D11C.ino)

## Pin connections

We first soldered microcontrollers (XIAO RP2040, XIAO ESP32C3, and XIAO SAMD21 with pin connectors. Then, we were smoothly able to plug it into the breadboard for a group assignment with ring oscillators.

![Measurementphoto](./assets/assignment4/schematic_photos/mikrocontrolledRP_soldered.jpg)
Figure: Example of a microcontroller board with soldered pin connectors.

The idea is to connect one input and one output pin together. In the programmed code the input will be read and the output will be set to the opposite boolean value.
This will result in a square wave of which frequency we will measure with the oscilloscope.

### XIAO RP2040

[RP2040 schematic](https://files.seeedstudio.com/wiki/XIAO-RP2040/res/rp2040_datasheet.pdf)

### XIAO ESP32C3

[ESP32C3 schematic](https://files.seeedstudio.com/wiki/XIAO_WiFi/Resources/Seeeduino-XIAO-ESP32C3-SCH.pdf)

### XIAO SAMD21

The code for this was not presumably specifically for the SAMD21 but an earlier model.
Therefore, there wasn't direct instructions on which pins to connect.
From the rather complex looking C code we were able to figure out that the pins used were
PA02 and PA04 which we found from the schematic.

[SAMD21 schematic](https://files.seeedstudio.com/wiki/Seeeduino-XIAO/res/Seeeduino-XIAO-v1.0-SCH-191112.pdf)



## Measurements 

We used Keysight InfiniiVision DSOX3102A, a digital storage oscilloscope to measure the frequencies of the square waves.

### Images of the procedure

The following figures show how made the connection between the programmed microcontroller and oscilloscope.


![Measurementphoto](./assets/assignment4/schematic_photos/ESP32C3.jpg)

![Measurementphoto](./assets/assignment4/schematic_photos/ESP32C3readings.jpg)

![Measurementphoto](./assets/assignment4/schematic_photos/SMD.jpg)

![Measurementphoto](./assets/assignment4/schematic_photos/RP22.jpg)

![Measurementphoto](./assets/assignment4/schematic_photos/RP22connections.jpg)

### Results

The following figures show measurements from the oscilloscope.

![oscilloscope measurement](./assets/assignment4/oscilloscope/RP2040.png)
Figure: XIAO RP2040 measurements

![oscilloscope measurement](./assets/assignment4/oscilloscope/ESP32C3.png)
Figure: XIAO ESP32C3 measurements

![oscilloscope measurement](./assets/assignment4/oscilloscope/SAMD21.png)
Figure: XIAO SAMD2 measurements

The signal frequencies for 
XIAO RP2040, XIAO ESP32C3, and XIAO SAMD2 are 
     10.2 MHz,    3.81 MHz, and     3.69 MHz respectively.
    
Since the processor clock speeds are different, it is interesting to calculate the signal frequency per processor speed.
This is shown in the following table.

||read in-out speed (MHz)|processor speed (MHz)|ratio|
|---|---|---|---|
|xiao RP2040|10.23|133|0.07692|
|xiao ESP32C3|3.81|160|0.02375|
|xiao SAMD21|3.69|49|0.07688|

Table: Signal frequencies, the processor clock speeds, and the ratio of the signal frequency to the processor speed.