Week 4 - Embedded Programming#
- Authors:
Kai Naito
,Asako Okazaki
,Kae Nagano
,Yosuke Tsuchiya
,Georg Tremmel
- Created:
3/9/2019
, Last Update:2/14/2023
Note
In previous years, Embedded Programming was in Week 8. For 2023 the requirement and usage of MCUs changed.
Assignments#
Refer to Assessment page
Group assignment#
- Compare the performance and development workflows for other architectures
Individual Assignments#
- Browse through the data sheet for your microcontroller
- Program a microcontroller development board
-
- to interact (with local input &/or output) and communicate (remotely)
- Extra credit: use different languages &/or development environments
Browse through the data sheet for your microcontroller#
- Find and browser through datasheet of your choosen processor.
- Prove that you browsed through the datasheet by making screenshots, annotations and comments.
TODO: Example
Learning Outcomes#
- Identify relevant information in a microcontroller data sheet.
- Implement programming protocols.
Tip
Find something in the data sheet to is relevant to your final project. Maybe the MCU already has a build-in sensor that can be used?
Have you?#
- Linked to the group assignment page
- Documented what you learned from browsing through a microcontroller datasheet.
- Programmed your board to interact and communicate
- Described the programming process(es) you used
- Included your source code
- Included ‘hero shot(s)’
How to enjoy Individual assignment#
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.
Programming the XIAO#
SeeedStudio’s family of XIAOs (小):
- Getting Started with Seeed Studio XIAO ESP32C3
- Programming the Seeed Studio XIAO RP2040 Arduino C, MicroPython, CircuitPython
- Getting Started with Seeed Studio XIAO SAMD21
The XIAOs are also compatibly with SeeedStudio’s Grove connector system. For that you need either the - XIAO Development Board or the - XIAO Grove Extension Board
Tip
You don’t neede to the XIAOs and Grove sensor to make this week’s assignment. Any other board and sensors are ok.
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.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.
- Kamakura 2020 group assignment
- Kamakura 2021 group assignment (ESP32, Microbit, M5 Stack)
- Kamakura 2022 group assignment Kuriyama(Raspberry Pi, Microbit), Indonesia(Esp8266, )
FabAcademy Boards#
- ARM Cortex M0+: hello.D11C.blink
- ARM Cortex M0+: hello.D21E.echo
- ARM Cortex M0+: SAMD21E Breakout
- Xtensa/WSP-WROOM-32
- Xtensa/ESP-WROOM-02
Other Boards#
-
- 英国BBCが教育用に開発したシングルボードコンピューター。光、加速度、温度などのセンサーに加え、LED表示器、ボタンなどを搭載する。IDEが充実している。 (MCU:32 bit ARM Cortex M0ベース Nordic nRF51822) Spec
- 開発環境
- Makecode : Block Editor(cloud)
- Python : Python Editor(cloud)
- C (Mbed IDEでも可能)
-
- Blue pillと呼ばれるSTM32F103C8を搭載した互換開発ボード
- ST-LINK V2 Programmer
- Getting Started with STM32 using Arduino IDE: Blinking LED
-
Mbed ARM社のプロトタイピング用ワンボードマイコンおよびそのデバイスのプログラミング環境
- Mbed Studio (開発環境)
-
ESP32-WROOM-32 Wi-FiとBluetoothを内蔵する低コスト、低消費電力なSoCのマイクロコントローラ。Espressif社が提供している。
Announcements#
- 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
Recitation#
Links#
- What is Make and Makefile
- ArduinoIDEでプログラムを書き込むセットアップ方法
- Bitwise operators
- AVR microcontroller beginner guide (youtube)
- Digging in to ArduinoIDE commands (youtube) シンプルなパルスを出すプログラムの処理時間を例にとり、ArduinoIDEのコマンドをC言語まで分解しながら、AtmelStudioを使ったCプログラミングについて解説している。
- FabAcademy Japan 昨年のサポートドキュメント(竹村さん作成)
Support Documents#
Class Video (recorded)#
- video
- note
Comment
Get different XIAOs and/or MicroMod with different processors. Use MicroBit, previous ATTiny dev boards. Programming of the board is necessary.