Skip to content

4. Embedded Programing

Learning Objectives

  • Implement programming protocols.

Schedule

Wednesday, Jan 21st - Global Class - Embeded Programing

Thursday, Jan 22nd: - Setup and Programing Into Password:

Friday, Jan 23rd: - Data Sheets and Specifications Password:

Assingments

Group assignment:

  1. Demonstrate and compare the toolchains and development workflows for available embedded architectures
  2. Document your work to the group work page and reflect on your individual page what you learned

Individual assignment:

  1. Browse through the datasheet for a microcontroller
    • documented some information from a microcontroller’s datasheet
  2. Write and test a program for an embedded system using a microcontroller to interact (with local input &/or output devices) and communicate: with remote wired or wireless connections
    • Programmed a board to interact and communicate
    • Described the programming process(es) you used
    • Included your source code

Class Content

General Info

Beginner Glossery

Term Simple Meaning
Microcontroller Small computer on one chip
CPU (Central Processing Unit) The brain
Flash Permanent memory (stores program)
SRAM (Static Random Access Memory) Temporary working memory
GPIO (General Purpose Input Output) Digital input/output pins
ADC (Analog-to-Digital Converter) Converts voltage into numbers
DAC (Digital-to-Analog Converter) Converts numbers into voltage
SERCOM (Serial Communication Module) Communication block
UART Simple serial communication method
SPI Fast serial communication method
I²C Two-wire communication method
DMAC (Direct Memory Access Controller) Moves data without CPU
MHz Millions of cycles per second
Level shifting Converting voltage levels safely

Link to class content on local site

  1. Arduino introductory development board
    • The biggest part is the micro controler. This is the part that we program.
    • When you program this, your code is the only thing running. this is different from a computer which runs a million things in parallel at once
  2. General over and history of computers
    • In general computers are computing matchines.
    • With this logic, the earlies computers where human brains
    • After this computers were mechanical using gears, shafts and cams. This is very difficult to change and maniplulate
    • Moving from physical to digital was a big step that allow easy manipulation through code
    • The corner we will be working on is: digital, bynary, general purpose
  3. Analog vs digital: digital is an approximation of a continous data stream

../../images/week4/digital_analog.jpg.jpg

  1. Hardware
    • pcb: printable circuite board (we will use this)
    • ict: integrated cirtuit technology
    • firmware vs. operating system: firmware runs directly on the hardware, an opperating system runs through another system?
  2. Compling
    • Turning human readible language to computer readible language

Setting up arduino software

Arduino software is used in the tool chain to load programs to your microcontroler.

Class Notes
  1. instal arduino from: https://www.arduino.cc/en/software/#ide

  2. Add aditional board managers

  3. first copying board manager url that you want to add
    • in this case we will copy from the class site
    • generally you can google search using the board name and “board manager”
  4. go to Arduino IDE —> settings to open pannel below. Paste the copied addional board manager links in to the available section and click ok.

../../images/week4/ardsettup_boardmng.jpg

  1. Instal the correct board: in this case esp32 by espressif
    • you can find the correct one by searching espressif

../../images/week4/ardsettup_boardinstal.jpg

  1. connect board
    • Select correct board from tools —> board —> ESP32S3 Dev Module
    • select correct port from tools —> port …
    • If board is continously connecting and disconnecting: hold down boot and click reset
  2. Writing code
    • there is a list of offical references at: https://docs.arduino.cc/language-reference/
    • Arduino specifc info from class: https://fablabbcn-projects.gitlab.io/electronics/barduino-docs/GettingStarted/pinout/
    • once you run you get a prompt saying “ Hard resetting via RTS pin” this is done by physically pushing the reset button
    • Syntax
      • functions: lowercase
      • class: first letter is uppercase

Virtual simulator

Link and uses
  • https://wokwi.com/
  • this is usefull when yo dont have the board or for debugging if errors are ocde based or hardware based

../../images/week4/ardsettup_simulator.jpg

  1. Microcontroller Circuits
    • anode: input - is denoted by the bent leg of a device
    • always color code
    • Input: measures the incoming voltage
    • output: sends the nominal voltage of the circuit based on the prgram that runs it
    • ports that specify a voltage always run a voltage (not programable)
    • GP: general purpose in and out (I/O)
    • in arduino software File —> Examples had very useful code examples that you can load automatically

## Exercise

Description and code

Create a program that will blink the LED in morus code SOS. We can use the blow class examples. The first beeps in morus code. the second turns on the LED.

Result

../../images/week4/ardsettup_blinklight_result.jpg

``` void setup() { // put your setup code here, to run once: Serial.begin(115200); Serial.println(“Hello, buddy!”);

pinMode(2, OUTPUT); }

void loop() {

digitalWrite(2, HIGH); tone(46, 440, 600); digitalWrite(2, LOW); delay(800); digitalWrite(2, HIGH); tone(46, 440, 600); digitalWrite(2, LOW); delay(800); digitalWrite(2, HIGH); tone(46, 440, 600); digitalWrite(2, LOW); delay(800);

digitalWrite(2, HIGH); tone(46,440, 200); digitalWrite(2, LOW); delay(400); digitalWrite(2, HIGH); tone(46,440, 200); digitalWrite(2, LOW); delay(400); digitalWrite(2, HIGH); tone(46,440, 200); digitalWrite(2, LOW); delay(400);

digitalWrite(2, HIGH); tone(46, 440, 600); digitalWrite(2, LOW); delay(800); digitalWrite(2, HIGH); tone(46, 440, 600); digitalWrite(2, LOW); delay(800); digitalWrite(2, HIGH); tone(46, 440, 600); digitalWrite(2, LOW); delay(800);

delay(1600);

} ```

Another example

../../images/week4/ardsettup_IO.jpg

this one is interesting becuase it works with an input that effects the output

Reading Data Sheets

Link to Friday slides

Friday Notes

Class Notes
  1. other interesting uses

    • silk screens
    • cutting iron on lettering for shirts
    • inflatables using thermo adhesive
    • copper tape for soft circut
  2. What we have in the lab

    • XIAO: micro controler + many other features (shofer)
    • CH32 (scooter)
    • ATTiny (moto)
    • ATSAMD (car)
    • ESP32 (luxury car)
    • RP2040 (sports car) close to a mini computer
  3. ATTiny
    • work flow for loading the program to the board is a bit tricky
    • if you use these make sure to use the new ones
    • Info: from data sheet
      • numbers at the top refer to versions with different memory. there are also different form factors so make sure you are designing to the form factor that you have.
      • CPU: speed
      • I2C: internet compatabilty
      • Analog to digital converstion (ADC) important for sensor conversion if you are using a sensor that does not do the conversion internally. The inverse is (DAC) digital to analog converter
      • Operates at 5 volts
      • Block diagram
        • There is a dot in the corner that also appears on the board. This is critical becuase it is the reference for the orientation of the board
        • pin SOIC
        • VDD: input supply
        • GND: ground
      • Pinout

Pinout from the data sheet

../../images/week4/specs_datasheet.jpg

  • numbers on the board are not the pin names
  • registers live are in the memory of the microcontroler (dont worry about it now)

Pinout created by users to make our lives easier

../../images/week4/specs_pinout.jpg

reading the pinout 1. Color Coding - Green row (registers): PA 0-7 name the 8 bits, PB not used in the 8 bit version - Orange and blue (definintion of the pin): real names of the pin 2. Setting up on arduino - follow link on slides (see link above) - copy and paste same as yesterday - find MegaTinycore and instal - Check in tools: Board, Port, SerialUPdI - Then: Burn boot loader (only if it is a microcontroler with a lot of storage - you would not use this with the ATTiny420) - to upload: Sketch —> upload using programmer

SMD 1. it has USB but it is not designed to be used for programing the borad 2. pin to prgram is through SWD: four pins (ground, reset, clock, data in and out) 3. you can use these to reprogram the board to be programed through USB. You only need to do this once and then you can just use USB


Inividual Assesment of Data Sheets

Critical Acronyms Reference

Acronym Meaning
MCU Microcontroller Unit
CPU Central Processing Unit
SRAM Static Random Access Memory
Flash Non-volatile program memory
ADC Analog-to-Digital Converter
DAC Digital-to-Analog Converter
DMA Direct Memory Access
RTC Real-Time Clock
GPIO General Purpose Input/Output
PWM Pulse Width Modulation
SERCOM Serial Communication Module
USART Universal Synchronous/Asynchronous Receiver/Transmitter
SPI Serial Peripheral Interface
I²C Inter-Integrated Circuit
SWD Serial Wire Debug
BOD Brown-Out Detector
POR Power-On Reset
TCC Timer/Counter for Control
TC Timer/Counter
DMAC Direct Memory Access Controller

Example: SAM D10 Analysis

STEP 1: The Description

From page 1:

ARM Cortex-M0+ processor, up to 48MHz, up to 16KB Flash, 4KB SRAM

Key Information

Item Why Its Important
ARM Cortex-M0+ 32-bit processor core (modern, efficient, low power)
Up to 48 MHz Maximum CPU speed
Up to 16KB Flash Program memory size
4KB SRAM Working memory (very small)
14–24 pins Physical size and I/O capability
Low power Good for battery applications

Important Acronyms

  • ARM → CPU architecture designer
  • Cortex-M0+ → Low-power 32-bit processor core
  • Flash → Non-volatile program memory
  • SRAM → Volatile working memory
  • MHz → Megahertz (millions of cycles per second)
  • DMA → Direct Memory Access

STEP 2 — Features

This is the fast evaluation page.

From page 2:

Processor

  • ARM Cortex-M0+ @ 48MHz
  • Single-cycle hardware multiplier

Not suitable for heavy digital signal processing or complex computation.


Memory

  • 8KB or 16KB Flash
  • 4KB SRAM

This is small by modern standards best for small firmware applications.

For comparison:

Device Flash
Arduino Uno 32KB
STM32F4 512KB – 2MB
SAM D10 8–16KB

Peripherals (Critical for Selection)

Peripheral Meaning Why Its Important
SERCOM (3) Flexible communication modules UART, SPI, I²C support
ADC (12-bit, 350ksps) Analog-to-Digital Converter Read sensors
DAC (10-bit) Digital-to-Analog Converter Output analog voltage
RTC Real-Time Clock Timekeeping
TCC / TC Timers PWM, motor control
DMAC Direct Memory Access Controller Efficient data transfers
PTC Peripheral Touch Controller Capacitive touch sensing

STEP 3 — Configuration Summary

This table compares package variants.

Package Pins GPIO ADC Channels SERCOM
24-pin 22 GPIO 10 ADC 3 SERCOM
20-pin 18 GPIO 8 ADC 3 SERCOM
14-pin 12 GPIO 5 ADC 2 SERCOM

Common Mistakes

  • Not enough GPIO
  • Not enough ADC channels
  • Not enough communication interfaces
  • Wrong package size for PCB

This table prevents those errors.


STEP 4 — Operating Voltage

Operating Voltage: 1.62V – 3.63V

Implications:

  • Not 5V tolerant
  • Requires 3.3V system
  • May require level shifting for 5V devices

STEP 5 — Block Diagram Overview

The block diagram shows:

  • CPU core
  • Memory
  • Bus system (AHB/APB)
  • Clock system
  • Power management
  • Debug interface (SWD)

Quick evaluation:

  • No USB
  • No CAN
  • No Ethernet

This is a simple control-oriented microcontroller.


STEP 6 — Ordering Information

Example part number:

ATSAMD10D14A-SSUT

Part Number Breakdown

Code Meaning
D10 Cortex-M0+
C/D Pin count family
14 16KB Flash
SS SOIC package
MUT QFN package
U/N Temperature range

Important notes:

  • 8KB and 16KB versions exist
  • 14-pin version has fewer peripherals

Most Important Selection Criteria

When evaluating any microcontroller:

  1. Flash & SRAM: Can your firmware fit?
  2. GPIO Count: Enough pins?
  3. Communication Interfaces: How many - UART? SPI? I²C?
  4. ADC Resolution & Speed: 12-bit? Channel count? Sampling speed?
  5. Operating Voltage: 3.3V only? 5V tolerant?
  6. Package Type: Can you manufacture or solder it?
  7. Power Consumption: Battery-powered project?
  8. Clock Speed: Performance requirements?

🎓Summary of SAM D10

Good For:

  • Small embedded projects
  • Capacitive touch
  • Low power control
  • Simple sensor nodes

Not Good For:

  • Large firmware
  • USB applications
  • High performance DSP
  • Networking projects

Note – chatGPT Helped me with this summary. The promp used: I am learning how to read data sheets for microcontrollers and would like your help. Please help me to identify the most important information when choosing if this is the right board to use for a project. I do not have a project in mind yet but want to learn how to read the sheet so that when I do have a project I can look quickly through the sheets to gather the most relevant info. in addition, please explain the meaning of acronyms and important technical terms that appear in the first 4 pages or else where in critical information.

test