コンテンツにスキップ

Week 4 - Embedded Programming#

  • Authors: Kai Naito, Asako Okazaki, Kae Nagano, Yosuke Tsuchiya, Georg Tremmel
  • Created: 3/9/2019, Last Update: 2/13/2025

Today’s Agenda#

  1. Quick check: This week’s assignment
  2. Hands-on: Playing around with Wokwi & RP2040 Datasheet : slide

Assignments & Goal#

Refer to Assessment page

Group assignment#

  • demonstrate and compare the toolchains and development workflows for available embedded architectures

Comment

  • Each student explores different board or workflow, then document the comparison.
  • You can use the example code, but try to modify some of it.

Individual Assignments#

  • 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)
  • extra credit: test it on a development board
  • extra credit: try different languages &/or development environments

Comment

This week, you won’t necessarily use the results of your group assignments in your individual work, so it doesn’t matter which one you do first.


Learning Outcomes#

  • Implement programming protocols.

Have you?#

Nueval check list

  • Linked to the group assignment page
  • Browsed and documented some information from your microcontroller’s datasheet
  • Programmed your simulated board to interact and communicate
  • Described the programming process(es) you used
  • Included your source code
  • Included ‘hero shot(s)’

How to enjoy assignment#

Data sheet for your microcontroller#

Recommendation:

  • RP2040
  • ESP32C3

  • Find and browser through datasheet of your choosen processor.

  • Prove that you browsed through the datasheet by making screenshots, annotations and comments.

Simulation#

WOKWI simulator

Programming the XIAO#

Other Boards#

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.

  • Change LED blinking cycle, pattern by text input
  • LED lighting by PWM
  • Neopixel: color pattern, position
  • Input/Output devices related to your Final Project
  • Dual core trial
  • Python + Thonney

Announcements#

Recitation#

Class Video (recorded)#


Old references#

  • Programming environments for the ATtiny(TinyAVR) 1-series.

Think is keep for historical reasons - and for students who want to work with the ATtinys. (ATtiny412, ATtiny1614, ATtiny3216)

Deep Dive: Programming the ATtiny with C

ATtiny (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'
SOURCES=$(PROJECT).c
DEVICE = tiny3216               # Target Processor
MMCU=at$(DEVICE)
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

$(PROJECT).out: $(SOURCES)
    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.

AVR C Programming / Make file#

AVR C Programming Reference#


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#

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.