Sign in Join
Wiki copytemporary

micro:bit: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: micro:bit

OldNewLine
1+The micro:bit is a small embedded system equipped with a Nordic Semiconductor nRF51822 controller based on the Cortex-M0 architecture. With FPC trunk, it is possible to build programs for it. Follow the instructions at [Embedded ARM](http://wiki.freepascal.org/TARGET_Embedded#ARM_Embedded) to setup FPC for the target arm-embedded. However, do not use the provided command line to build and install FPC but use
2+
3+` make clean buildbase installbase CROSSINSTALL=1 OS_TARGET=embedded CPU_TARGET=arm SUBARCH=armv6m`
4+
5+instead to build FPC for the controller used by the micro:bit.
6+
7+Now enter the following program:
8+
9+``` pascal
10+ const
11+ GPIO_PIN_CNF_INPUT_Disconnect = 1;
12+ GPIO_PIN_CNF_DIR_Output = 1;
13+ microbit_led_col1 = 4;
14+ microbit_led_row1 = 13;
15+ var
16+ i : longint;
17+ begin
18+ GPIO.PIN_CNF[microbit_led_col1]:=(GPIO_PIN_CNF_INPUT_Disconnect shl 1) or GPIO_PIN_CNF_DIR_Output;
19+ GPIO.PIN_CNF[microbit_led_row1]:=(GPIO_PIN_CNF_INPUT_Disconnect shl 1) or GPIO_PIN_CNF_DIR_Output;
20+ while true do
21+ begin
22+ GPIO.OUTSET:=1 shl microbit_led_row1;
23+ GPIO.OUTCLR:=1 shl microbit_led_col1;
24+ for i:=1 to 500000 do
25+ asm
26+ nop
27+ end;
28+ GPIO.OUTCLR:=1 shl microbit_led_row1;
29+ for i:=1 to 500000 do
30+ asm
31+ nop
32+ end;
33+ end;
34+ end.
35+```
36+
37+save it as example.pp and compile it with:
38+
39+` fpc -Parm -Tembedded -Wpnrf51822_xxaa example -Cparmv6m`
40+
41+When connecting a micro:bit to PC, it identifies itself as an USB drive. Find out where this drive is located and copy the resulting example.hex to this drive.
42+
43+If everything worked fine, the upper left LED will blink.
44+
45+---
46+*From the Free Pascal wiki, page "micro:bit", as it stood on 2019-12-17 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
47+Category: ARM
48+Category: Embedded
49+Category: Microcontrollers
50+Category: Operating Systems and Platforms

Back to history