micro:bit: what changed
Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | 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 | 2 | ||
| 3 | - | ||
| 3 | + | ```text | |
| 4 | + | make clean buildbase installbase CROSSINSTALL=1 OS_TARGET=embedded CPU_TARGET=arm SUBARCH=armv6m | |
| 5 | + | ``` | |
| 4 | 6 | ||
| 5 | 7 | instead to build FPC for the controller used by the micro:bit. | |
| 6 | 8 | ||
| 7 | 9 | Now enter the following program: | |
| 8 | 10 | ||
| 9 | 11 | ``` pascal | |
| 10 | 12 | const | |
| 11 | 13 | GPIO_PIN_CNF_INPUT_Disconnect = 1; | |
| 12 | 14 | GPIO_PIN_CNF_DIR_Output = 1; | |
| 13 | 15 | microbit_led_col1 = 4; | |
| 14 | 16 | microbit_led_row1 = 13; | |
| 15 | 17 | var | |
| 16 | 18 | i : longint; | |
| 17 | 19 | begin | |
| 18 | 20 | GPIO.PIN_CNF[microbit_led_col1]:=(GPIO_PIN_CNF_INPUT_Disconnect shl 1) or GPIO_PIN_CNF_DIR_Output; | |
| 19 | 21 | GPIO.PIN_CNF[microbit_led_row1]:=(GPIO_PIN_CNF_INPUT_Disconnect shl 1) or GPIO_PIN_CNF_DIR_Output; | |
| 20 | 22 | while true do | |
| 21 | 23 | begin | |
| 22 | 24 | GPIO.OUTSET:=1 shl microbit_led_row1; | |
| 23 | 25 | GPIO.OUTCLR:=1 shl microbit_led_col1; | |
| 24 | 26 | for i:=1 to 500000 do | |
| 25 | 27 | asm | |
| 26 | 28 | nop | |
| 27 | 29 | end; | |
| 28 | 30 | GPIO.OUTCLR:=1 shl microbit_led_row1; | |
| 29 | 31 | for i:=1 to 500000 do | |
| 30 | 32 | asm | |
| 31 | 33 | nop | |
| 32 | 34 | end; | |
| 33 | 35 | end; | |
| 34 | 36 | end. | |
| 35 | 37 | ``` | |
| 36 | 38 | ||
| 37 | 39 | save it as example.pp and compile it with: | |
| 38 | 40 | ||
| 39 | - | ||
| 41 | + | ```text | |
| 42 | + | fpc -Parm -Tembedded -Wpnrf51822_xxaa example -Cparmv6m | |
| 43 | + | ``` | |
| 40 | 44 | ||
| 41 | 45 | 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 | 46 | ||
| 43 | 47 | If everything worked fine, the upper left LED will blink. | |
| 44 | 48 | ||
| 45 | 49 | --- | |
| 46 | 50 | *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 | 51 | Category: ARM | |
| 48 | 52 | Category: Embedded | |
| 49 | 53 | Category: Microcontrollers | |
| 50 | 54 | Category: Operating Systems and Platforms |
