MAS.863/4.140/6.9020
How To Make (almost) Anything
EECS Section
2024

Week 3: Embedded Programming

Group Project: Demonstrate and compare the toolchains and development workflows for alternative embedded architectures.

Within a microcontroller, there are different embedded architectures:

1. Von Neumann Architecture

- Single bus for instruction and data.
- Program code and data share the same memory space.

2. Harvard Architecture

- Separate buses/memory spaces for instructions and data.
- Enables parallel data and instruction fetches.

3. Microcontroller Architectures

MCUs designed specifically for different microcontroller workflows.

AVR (Atmel - Modified Harvard Architecture)

- Architecture: Separate program and data memories but with a single unified address space.
- Example: ATmega328P
- Uses Harvard architecture: separate memories and buses for program and data.
- 32 8-bit general-purpose registers connected to the Arithmetic Logic Unit (ALU).

Programming Workflow for AVR:

1. Code in C/C++ using the Arduino IDE.
2. Compile into a binary hex file.
3. Flash the binary into the microcontroller’s program memory (using Arduino IDE or another tool).

Initialization:
  • Power Supply:
    • V_in: Supply external voltage directly to the board.
    • Power Jack: External power source, e.g., power adaptor.
    • USB Connector: Connect to a computer for both power and programming.
  • Wire Up Digital/Analog Pins:
    • Digital Pins (Port 0-13): Input or output digital signals.
    • Analog Pins (A0-A5): For analog signals (0 V to 5 V).
    • AREF: Analog Reference for ADC or external reference voltage.
    • Power Pins: 5V, 3.3V pins for powering other components (low current).
    • Other Pins:
      • RESET: Restarts the program.
      • SCL/SDA: I2C communication (clock and data lines).
      • MISO/MOSI/SCK: SPI communication pins.
      • CS: Chip select for multiple devices.

ARM Architecture (Based on RISC Architecture)

- ARM is a RISC-based architecture with better performance compared to AVR.
- Registers are 32-bit (compared to AVR’s 8-bit), allowing for more complex and powerful operations.

Example: RP2040

- Dual ARM Cortex-M0+ cores.
- Flexible programming workflows:

  • C/C++ SDK: Use the official Raspberry Pi Pico SDK.
  • Arduino IDE: Compatible with Arduino for simplified programming.
  • MicroPython: Script using Python for rapid prototyping.

- Pins and functionality are similar to AVR but offer greater flexibility and performance.