FAB ACADEMY 2024 
FABLAB U. CONTINENTAL, PERU

Embedded Programming


I will show information about the two computer architectures :

The von Neumann architecture — also known as the von Neumann model or Princeton architecture — is a computer architecture based on a 1945 description by John von Neumann, and by others, in the First Draft of a Report on the EDVAC. 

The document describes a design architecture for an electronic digital computer with these components:

  • A processing unit with both an arithmetic logic unit and processor registers
  • A control unit that includes an instruction register and a program counter
  • Memory that stores data and instructions
  • External mass storage
  • Input and output mechanisms

The Harvard architecture is a computer architecture with separate storage and signal pathways for instructions and data. It contrasts with the von Neumann architecture, where program instructions and data share the same memory and pathways.

The term originated from the Harvard Mark I relay-based computer, which stored instructions on punched tape (24 bits wide) and data in electro-mechanical counters. These early machines had data storage entirely contained within the central processing unit, and provided no access to the instruction storage as data. Programs needed to be loaded by an operator; the processor could not initialize itself.

In summary the main difference between the two is access to data memory and program memory. So:

  • Von Neuman architecture has a single bus that is used to obtain instructions and transfer data.
  • Harvard architecture has a separate memory space for instructions and data, physically separates signals and code from storage and memory.

In this Fab Academy I used the XIAO RP2040 (Von Neumann). It has a ARM Architecture

ARM Architecture

The Cortex-M0+ processor is a configurable, multistage, 32-bit RISC processor. It has an AMBA AHB-Lite interface and includes an NVIC component. It also has hardware debug, single-cycle I/O interfacing, and memory-protection functionality. The processor can execute Thumb code and is compatible with other Cortex-M profile processors.

The M0+ features:

• The ARMv6-M Thumb® instruction set.

• Thumb-2 technology.

• An ARMv6-M compliant 24-bit SysTick timer.

• A 32-bit hardware multiplier. This is the standard single-cycle multiplier

• The ability to have deterministic, fixed-latency, interrupt handling.

• Load/store multiple instructions that can be abandoned and restarted to facilitate rapid interrupt handling.

• C Application Binary Interface compliant exception model. This is the ARMv6-M, C Application Binary Interface (CABI) compliant exception model that enables the use of pure C functions as interrupt handlers.

• Low power sleep-mode entry using Wait For Interrupt (WFI), Wait For Event (WFE) instructions, or the return from

interrupt sleep-on-exit feature.

XIAO RP2040

The Seeed Studio XIAO RP2040 is as small as the Seeed Studio XIAO SAMD21 but it's more powerful. On one hand, it carries the powerful Dual-core RP2040 processor that can flexible clock running up to 133 MHz which is a low-power microcontrollers. On the Seeed Studio XIAO RP2040 there is also 264KB of SRAM, and 2MB of on-board Flash memory which can provide more program to save and run. On the other hand, this little board has good performance in processing but needs less power. All in all, it is designed in a tiny size as small as a thumb(20x17.5mm) and can be used for wearable devices and small projects.

There are 14 GPIO PINs on Seeed Studio XIAO RP2040, on which there are 11 digital pins, 4 analog pins, 11 PWM Pins,1 I2C interface, 1 UART interface, 1 SPI interface, 1 SWD Bonding pad interface.


Datasheet

https://files.seeedstudio.com/wiki/XIAO-RP2040/res/rp2040_datasheet.pdf

Specification

CPU

Dual-core ARM Cortex M0+ 

processor up to 133MHz

Flash Memory

2MB

SRAM

264KB

Digital I/O Pins

11

Analog I/O Pins

4

PWM Pins

11

I2C interface

1

SPI interface

1

UART interface

1

Power supply and 

downloading interface

Type-C

Power

3.3V/5V DC

Dimensions

20×17.5×3.5mm

Pinout



Software

This time use the Arduino IDE to configure this board. We need to perform some steps to achieve it.

First we need to install the classic Arduino IDE.

Then we enter Preferences and add a line in Board Manager. https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json


Then navigate to Tools - Board - Boards Manager, and install this Raspberry Pi Pico/RP2040 device. 

Finally, we configure the port and board parameters. 


Components used:

01 Xiao RP2040

03 LED


Arduino IDE:

The open-source Arduino Software (IDE) makes it easy to write code and upload it to the board. This software can be used with any Arduino board. Active development of the Arduino software is hosted by GitHub. See the instructions for building the code. 

Download:

Get the Arduino IDE form its official site.

https://github.com/arduino/Arduino/releases/latest

Installation:

Whe the download was finished, install software. Next, default folder and parameters.

Arduino IDE Project

Next, open the Arduino IDE, and select File, Samples, 01. Basics, Blink.

A blink led sample code was opened.

To use the ICSP programmer we need to select it. Go to Tools menu, Programmer, USBTinyISP


Code / Firmware

/*

  Blink


  Turns 03 LEDS on for a half one second, then off for half one second, repeatedly.



  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(D0, OUTPUT);

  pinMode(D1, OUTPUT);

  pinMode(D2, OUTPUT);

}


// the loop function runs over and over again forever

void loop() {

 // digitalWrite(0, HIGH);  // turn the LED on (HIGH is the voltage level)

  //delay(1000);                      // wait for a second

  digitalWrite(D0, HIGH);   // turn the LED off by making the voltage LOW

  delay(500);                      // wait for a second

  digitalWrite(D0, LOW);   // turn the LED off by making the voltage LOW

  delay(500);                      // wait for a second


  digitalWrite(D1, HIGH);   // turn the LED off by making the voltage LOW

  delay(500);                      // wait for a second

  digitalWrite(D1, LOW);   // turn the LED off by making the voltage LOW

  delay(500);                      // wait for a second

  

  digitalWrite(D2, HIGH);   // turn the LED off by making the voltage LOW

  delay(500);                      // wait for a second

  digitalWrite(D2, LOW);   // turn the LED off by making the voltage LOW

  delay(500);                      // wait for a second

  

}

Circuit



Testing

Connecting the Xiao to LEDS to test.

Takeaways Assignment

  • The XIAO module is very versatile due to its power and small size. It allows performing functions from the simplest to the most complex and using the classic Arduino IDE
  • This module is easy to program through its serial interface through the USB port, allowing us to program it quickly.
Back, Assignment 05: 3D Scanning and Printing Next, Assignment 07: Computer Controlled Machining