Embedded Programming

architectures
   von Neumann, Harvard, bugs
   RISC, CISC
   microprocessor, microcontroller
   multi-core
   GPU, embedded
   FPGA, TinyFPGA, IceStorm, Symbiflow
   SiliconCompiler
   spatial

memory
   registers (instructions)
   SRAM (fast)
   DRAM (big)
   EEPROM (non-volatile)
   FLASH (programs, strings)
   fuse (configuration)

peripherals
   ports
   A/D
   comparator
   D/A
   timer/counter/PWM
   USART
   USB
   math
   crypto
   ...

word size
   8
   16
   32
   64

processor families
   hardware, software benchmarks
   LOGIC
   Megaprocessor
   MOnSter 6502
   8051
   PIC
   MSP
   AVR
         • 6-100 pin packages
      ATtiny10
         • SOT23-6
      ATtiny45V, ATtiny44A
         • prior
      ATtiny412, ATtiny1614, ATtiny3216
         • 1-series
         • 8 bit, 1.8-5.5V, 20 MHz
         • single-cycle global instructions
         • simple peripheral register access
         • low pin-count packages
         • one-pin serial programming
      ATtiny1624
         • 2-series
         • programmable gain amplifier
      AVR128DB32
         • 24 MHz
         • analog signal conditioning
         • level shifting
         • hardware multiplier
   ARM
      D11C, D11D, D21E, D51
         • 32 bit, 1.6-3.6V
         • 48 MHz clock, more complex clock distribution and synchronization
         • more powerful peripherals, more complex register access and libraries
         • diverse family, larger packages
         • standard in-circuit debugging
      STM32
         • 8-265 pins
         • good software support
      Raspberry Pi
         RP2040
            • 32-bit dual-core
            • 133 MHz clock (250 MHz+ over-clocked)
            • 264k SRAM
            • programmable peripherals
         RP2350
   Xtensa (MIPS)
      ESP8266, ESP32
         • integrated RF, networking
   RISC-V
         • open architecture
         • ESP32-C3, ESP32-C6
   PSoC, xCORE, Propeller, Lattice, NVIDIA
         • parallel

vendors
   Octopart
   Digi-Key
   Mouser
   Newark
   Farnell
   SparkFun
   Adafruit

packages
   DIP
   SOT
   SOIC
   TSSOP
   TQFP
   LQFP
   MLF, WLCSP, BGA

embedded languages
   modifying code
   assembly
      hex file
      instruction set, opcodes
      mnemonics, directives, expressions
      avr-as
      inline
   C C++
      programming types
      GCC
         make files (tabs)
         bit operations
      AVR
         libc modules types math benchmarks
         avr-libc binutils-avr gcc-avr
         homebrew-avr
      ARM
         gcc-arm-none-eabi gdb-multiarch
         homebrew-arm
         libopencm3
      Microchip
         Studio
         toolchains packs (zip)
         ASF START
      Espressif
         ESP-IDF
         ESP-DSP
   Rust Go
      memory leaks, memory overruns, race conditions
   interpreters
      MicroPython CircuitPython
         language implementation REPL speed bridge
         boot.py, main.py
         ulab
      Espruino Kaluma DeviceScript

in-system development
   raw REPL, Web REPL, upy.py
   bootloader, bootloaders
   JTAG SWD (ARM)
      software
         OpenOCD
         EDBG
               program: edbg -b -t target_type -epv -f binary_file
               read fuses: edbg -b -t target_type -F r,*,file_name
               write fuses: edbg -b -t target_type -F w,high_bit:low_bit,bit_value
               disable SAMD bootloader protection: edbg -b -t target_type -F w,2:0,7
      hardware
         Atmel-ICE PICO GoodFET Raspberry Pi
         Free-DAP
            USB-D11C-SWD-10 pin board components traces traces+exterior interior
               USB-D11C-SWD-4 pin board components traces traces+exterior interior
               SWD-10-4-0.05 pitch board components traces traces+exterior interior
               SWD-10-4-0.1 pitch board components traces traces+exterior interior
               binary video
            USB-D11C-SWD-10 pin Eagle brd sch
            USB-D11C-SWD-10 pin KiCad sch pcb prl pro 
            USB-D11C-SWD-10 pin SVG-PCB js
   UPDI (newer AVR)
      software
         pyupdi
            install:
               pip3 install intelhex pylint pyserial
            program:
               python3 pyupdi.py -d your_processor -c your_port -b your_baud_rate -f your_hex_file -v
         pymcuprog
            install:
               apt install libusb-1.0-0-dev, libudev-dev
               pip3 install pymcuprog
            program:
               pymcuprog -d your_processor -t uart -u your_port -c your_baud_rate -v info erase
               pymcuprog -d your_processor -t uart -u your_port -c your_baud_rate -v info write -f your_hex_file
      hardware
         USB-D11C-serial board components top top+exterior interior
            bootloader SAMD11C SAMD11C_serial video
            serial-UPDI-2 pin board components traces traces+exterior interior connector(less)
            serial UPDI-3 pin board components traces traces+exterior interior
         USB-FT230X-UPDI board components traces traces+exterior interior
         dual serial
   SWD+UPDI
   ISP (original AVR)
      software
         avrdude
      hardware
         header pads clip pins
         Atmel-ICE
         Arduino
         ATmega16U2 Zaerc
         ATtiny45 Sean Alex Tomás Jonathan Brian Zaerc
         ATtiny44 Ali Valentin Bas Andy David 
            USB-t44-ISP board components traces traces+exterior interior firmware.zip programming
   breakout

development environments
   Microchip Studio
   Eclipse
   VS Code
   Thonny
   Codebra
   PlatformIO
   Arduino
      board + toolchain + libraries + IDE + bootloader + header
      programming
         C++ Create Codebender Ardublock CLI
      original
         Fabkit Fabio satshakit hello.328P
      cores
         Arduino-Pico ESP32 ESP8266 fab-sam tinyAVR DxCore ATTinyCore 
      overhead millis interrupts ISR

development boards
   XIAO (CT) Adafruit Pololu Olimex Micro:bit Beagle Rasberry Pi
   Quentorres Fab-Xiao SAMDino Adrianino D11C devkit D21E devkit

operating systems
   bare-metal
   cooperative vs preemptive multitasking
   FreeRTOS TinyOS Mbed OS ROS

clocks
   types
      RC (10%, 1% calibrated)
      ceramic (0.5%)
      quartz (50 ppm)
   PLL
   instruction cycles
   overclocking
   underclocking

serial communication
   RS232
      bit timing
   VT100/ANSI/ISO/ECMA terminal
      Arduino serial monitor
      Screen 
         screen port speed, ctrl-a k to quit
      pySerial miniterm
         python -m serial.tools.miniterm /dev/your_device_port your_baud_rate
      SerialPort terminal
         serialport-terminal
      Web Serial
   USB
      ASF Arduino TinyUSB
      USB-D11C-serial board components top interior
         bootloader serial.ino video SAMD11C_serial
   FTDI
      drivers libFTDI cable chip
         hello.USB-serial.FT230X board components traces traces+exterior interior

RP2040
   XIAO pinout
      hello.button-blink.RP2040 board components traces interior
         hello.button-blink.RP2040.1.ino 1.py 2.ino 2.py video
         blink-echo.ino blink-echo.py ws2812.py video
   Pico Doom

ESP32
   ESP32-C3 XIAO pinout
      hello.button-blink.C3 board components traces interior
         hello.button-blink.C3.ino hello.button-blink.C3.py video
   ESP32-WROOM-32 module versions
      ESP32-WROOM-echo board components traces traces+exterior holes interior
         echo.ino video ring.ino
         Python video

ESP8266
   ESP-01 module
      ESP-01-echo board components traces traces+exterior holes interior
         echo.ino video
   ESP-WROOM-02D module
      ESP-WROOM-02D-echo board components traces traces+exterior holes interior
         echo.ino video
         Python video

ATSAMD11C
   D11C-blink board components traces traces+exterior interior
      D11C-blink-reset board components traces traces+exterior interior
      D11C-blink-reset-clock board components traces traces+exterior interior
      blink.c blink.make bootloader blink.ino video ring.ino
   D11C-echo board components traces traces+exterior interior
      D11C-echo-10 board components traces traces+exterior interior
      D11C-echo-mini board components traces traces+exterior holes interior
      D11C-echo-micro board components traces traces+exterior holes interior
      echo.ino video 
   D11C-serial board components top interior
      D11C-serial-micro-4 board components traces traces+exterior holes interior
      D11C-serial-large vias board components top top+exterior bottom holes interior
      D11C-serial-small vias board components top top+exterior bottom holes interior Gerber
      serial.ino video SAMD11C_serial

ATSAMD11D
   D11D-echo board components traces traces+exterior interior
      openocd.cfg bootloader echo.ino video

ATSAMD21E
   D21E-echo board components traces traces+exterior interior
      bootloader echo.ino video
      Python

ATSAMD51
   hello worlds ring.ino

ATtiny412
   t412-blink-3 pin board components traces mask traces+exterior interior
      blink.ino blink.c make video
   t412-blink-2 pin board components traces traces+exterior interior
      blink.ino video ring.ino
   t412-echo board componenets traces traces+exterior interior
      echo.ino video
      echo.c echo.make video

ATtiny45
   t45-echo board components traces traces+exterior interior pin re-use
      ports port.c port.make port.ino port.write.ino
      bit-bang echo.c echo.make echo.ino echo.serial.ino video

ATtiny1614 ATtiny1624
   t1614-echo board components traces traces+exterior interior
      echo.ino video

ATtiny44
   t44-echo board components traces traces+exterior interior
   t44-echo-2 sided board components top top+exterior bottom holes interior
      programming mods
      echo.c echo.c.make
      echo.interrupt.c echo.interrupt.c.make
      echo.asm echo.asm.make

ATtiny3216 ATtiny3226
   t3216-echo board components traces traces+exterior interior
      echo.ino video

AVR128DB32
   128DB32-echo board components traces traces+exterior interior
      ring.c ring.make echo.c echo.make video

debugging
   simulation
      digital
         Wokwi video
      mixed-signal
         AVR8js video
   software
      blink LED
      add print statements
      use embedded debugger
         gdb, ddd
         Microchip Studio
         Arduino 2
   hardware
      inspect, reflow solder joints
      check component orientation, values
      verify data sheets
      confirm connector orientation
      measure supply voltages
      probe I/O signals

AI
   embedded
      TensorFlow Lite TinyML ESP-DL Edge Impulse
   coding
      ChatGPT Copilot DeepSeek
         bugs, hallucination, copyright infringement, ...

assignment assignment assignment
   group assignment:
      demonstrate and compare the toolchains and development workflows
         for alternative embedded architectures
   individual assignment:
      browse through the data sheet for your microcontroller
      write a program for a microcontroller,
         and simulate its operation,
         to interact (with local input &/or output devices)
         and communicate (with remote wired or wireless connections)
         its operation
      extra credit: test it on a development board
      extra credit: try different languages &/or development environments