BBC micro:bit
The BBC micro:bit is a tiny programmable computer designed for learning. It is based on the Nordic Semiconductor nRF51822 ARM Cortex MO chip.
Interfaces
Interface | Hardware Supported | TinyGo Support |
---|---|---|
GPIO | YES | YES |
UART | YES | YES |
SPI | YES | YES |
I2C | YES | YES |
ADC | YES | Not yet |
PWM | Software support | Not yet |
Machine Package Docs
Documentation for the machine package for the BBC micro:bit
Flashing
DAPLink
The micro:bit comes with the DAPLink bootloader already installed. This means you can just copy the compiled .hex
file generated by TinyGo onto it, no additional flashing software is needed.
Plug your micro:bit into your computer’s USB port.
The micro:bit board will appear to your computer like a USB drive.
Build and flash your TinyGo program using
tinygo flash
like this:
tinygo flash -target=microbit [PATH TO YOUR PROGRAM]
- The micro:bit should restart and begin running your program.
OpenOCD
An alternative approach to load programs onto the micro:bit is by using the openocd
command line utility program. You must install OpenOCD before you will be able to flash the micro:bit board with your TinyGo code.
Plug your micro:bit into your computer’s USB port.
Build and flash your TinyGo program using
tinygo flash -target=microbit
Notes
The micro:bit has two built-in I2C devices, a MMA8653 accelerometer and a MAG3110 magnetometer. You can use them via the I2C0 bus.
The micro:bit I2C0 and SPI0 buses both share the same address space. This means you cannot use them both at the same time. However, you can still use both SPI and I2C at the same time, by using the SPI1 bus with the standard SPI pins at the same time as using the I2C0 bus to access the built-in devices.
For example:
// use the same pins as for SPI0, but with SPI1
machine.SPI1.Configure(machine.SPIConfig{
SCK: machine.SPI0_SCK_PIN,
MOSI: machine.SPI0_MOSI_PIN,
MISO: machine.SPI0_MISO_PIN,
Frequency: 500000,
Mode: 0})
// use I2C0 as normally do
machine.I2C0.Configure(machine.I2CConfig{})