Week 8 - Embedded Programming#

  • Author : Kai Naito / Asako Okazaki (Fablab Kamakura)
  • Date created : 3/9/2019
  • modified: 3/16/2020
  • modified: 3/13/2021 Kae Nagano
  • modified: 3/16/2022 Yosuke Tsuchiya
  • modified: 3/17/2022 Georg Tremmel


Refer to Assessment page

Group assignment#

  • Compare the performance and development workflows for other architectures


  • Compare at least two different microcontroller families other than AVR. Such as ARM and Xtensa
  • Programming of the board is necessary.

Individual Assignments#

  • Read Browse the Data Sheet for your Microcontroller
  • Use your programmer to program your board to do something
  • Extra credit: try other programming languages and development environments


  • Read the ATtiny3216 datasheet and document what you learned. Focus on features that are interesting to you and that you might use in your Final Project.

  • There are a lot of pages, but check all the chapters as much as you can to see what’s there.

  • Make a code to do something on your own board that they made in Electronics Design Week
  • Program the code into your PCB by using your own programmer that you made in Electronics Production.
  • The program should be better to interact the button and the LED
    • ex. if the button is pushed, the LED will blink…

Learning Outcomes#

  • Identify relevant information in a microcontroller data sheet.
  • Implement programming protocols.

Have you?#

  • Linked to the group assignment page
  • Documented what you learned from reading a microcontroller datasheet.
  • Programmed your board
  • Described the programming process/es you used
  • Included your source code
  • Included a short ‘hero video’ of your board

How to enjoy Individual assignment#

Programming Environment#

Examples of the environment when you program tinyAVR 1-series.

tinyAVR(1-series) C environment#

  • Download toolchain from Microchip site.

  • Download ATtiny_DFP atpack from Atmel ATtiny Series Device Support packs. 
    Change the file extention from .atpack to .zip, then unzip it.

  • Install python utility pyupdi. Refer to the software part of the document. tinyAVR 1-series

  • Write the path to ATtiny_DFP atpack at “PACK=” part of Makefile.

PROJECT=blinc_3216              # project name of your file, my C file is called 'blink_3216.c'
DEVICE = tiny3216               # Target Processor
F_CPU = 20000000
PACK = /Users/georg/Documents/avr/Atmel.ATtiny_DFP.1.9.337      # Absolute Path to ATtiny Lib
PORT = /dev/tty.usbserial-D307OEPA                              # Serial Port or your Programmer, find with lsusb
BAUD = 57600

CFLAGS=-mmcu=$(MMCU) -Wall -Os -DF_CPU=$(F_CPU)

$(PROJECT).hex: $(PROJECT).out
    avr-objcopy -O ihex $(PROJECT).out $(PROJECT).hex;\
    avr-size --mcu=$(MMCU) --format=avr $(PROJECT).out

    avr-gcc $(CFLAGS) -I./ -I$(PACK)/include -B$(PACK)/gcc/dev/$(MMCU) -o $(PROJECT).out $(SOURCES)

pyupdi: $(PROJECT).hex
    pyupdi -d $(DEVICE) -c $(PORT) -b $(BAUD) -v -f $(PROJECT).hex

Once your make file is configured, run the following command in your shell:

make -f hello.t412.3 .blink.make
make -f hello.412.3.blink.make pyupdi

This will upload the program to your MCU.

Some Programming Ideas#

There is no need to program the code from scratch - but you need to write an original program. Let’s start by changing Neil’s code.

  • LED blinking cycle
  • LED blinking pattern
  • LED lighting by PWM
  • Mode transition by button (e.g. LED blinking pattern)
  • Mode transition by text input (based on echo program)
  • LED blink by interrupt by button
  • Button ON turns LED ON, Button OFF turns LED OFF
  • Button ON switches STATE of LED (fron ON to OFF, and from OFF to ON)
  • Measure time between BUTTON Pushes, blink LED according to that time

Interesting examples unique to microcomputers

  • hello.t412.blink.ino
    Neil is comparing the speed of LED ON/OFF by the usual Arduino DigitalWrite and bit operation.

  • ring.t412.ino

  • ring.ESP32.ino
    Directly connect the output pin and input pin to oscillate, and measure the performance of the microcontroller from its frequency. >> GPIO test

  • hello.ftdi.44.echo.c
    Sample codes that are commonly used on each board. Wait in a loop until serial_pin_in goes low, then detect start bit and start communication.

  • hello.ftdi.44.echo.interrupt.c
    echo program using serial_pin_in pin change interrupt.

Local Recitation : AVR C Programming / Make file#

AVR C Programming Reference#

How to enjoy Group assignment#

Try your favorite board from the list below. If you have a board that you want to use in your final project, this is a great opportunity to try it out.

FabAcademy Boards#

Other Boards#


  • Prepare Final project page.
  • Short videos should be compressed and put into a repository without using external services.
  • Start Nueval

Nueval (evaluation system)#

Cut off date will be scheduled. Current plan is as follows.

  • June 29 Local evaluation to Global evaluation
  • July 13 Global evaluation to Student
  • July 27 final deadline to finish 2022 Cycle


3/14 Programming Recitation

Support Documents#

Class Video (recorded)#