This repository contains code for the experiments that are described in the book, Bare metal micro:bit, configured for the V2 micro:bit with an nRF52833 microcontroller chip.
Note than in August, 2024, I published a new revision of the code that
uses a changed convention UART.TXD
for referring to device
registers, in place of the convention UART_TXD
that was used before.
This means changes to almost every source file, and will break any
code that others have added to a fork of the repository. This won't
happen again.
Each experiment has a separate directory containing all the files it needs:
Directory | Description |
---|---|
x01-echo |
Building a program: Check that you can build and upload a simple program. |
x02-instrs |
Machine instructions: Investigate the effect of single machine instructions. |
x03-loops |
Loops: Write programs for multiplication and division that contain loops. |
x04-numbers |
Numbers: Explore number representations and conditional branches. |
x05-subrs |
Subroutines: Learn how to define and call subroutines to give structure to a larger program. |
x06-arrays |
Memory and arrays: Exploit instructions that load and store data in RAM. |
x07-hack |
A buffer overrun attack: Build a working (but harmless) model of a computer virus. |
x08-heart |
Digital input/output: Use device registers to control I/O pins and light LEDs. |
x09-pureasm |
Pure assembly language: Flash an LED with a minimal program written in assembly language. |
x10-serial |
Serial communication: Use a serial device to transmit characters. |
x11-interrupts |
Interrupts for I/O: Control the serial device with interrupts to free the processor. |
x12-intrmech |
Interrupt mechanism: Plot gaps in a waveform to measure the time needed to handle interrupts. |
x13-neopixels |
Neopixels: Use assembly language to make a bit-banged implementation of the protocol for WS2812 'NeoPixel' LEDs. |
x14-processes |
Processes: Use micro:bian processes to perform multiple tasks concurrently. |
x15-messages |
Messages: Use messages to communicate between processes. |
x16-sync |
Synchronisation: Synchronise the actions of multiple processes by making them exchange messages. |
x17-drivers |
Device drivers: Manage I/O devices using driver processes that receive interrupts as messages. |
x18-level |
I2C-based spirit level: Access the micro:bit accelerometer over the I2C bus to make a 2D spirit level. |
x19-servos |
Servo motors: Use a timer to generate the signals needed to control servo motors. |
x20-radio |
Radio: Communicate between multiple micro:bits using the in-built radio. |
x21-car |
Remote-controlled car: Use servos and radio to make a remote-controlled car. |
x31-adc |
Analog to digital converter: A device driver for the analog to digital converter. |
x32-infrared |
Infrared remote control: A program that uses GPIO interrupts to decode signals from an infrared remote control. |
x33-clock |
Neopixel clock: Software for a Neopixel-based clock. |