Description
Description
- Type: Bug
- Priority: Minor
Bug
Target
BBC micro:bit
mbed-os sha:
7669d7f
Expected behavior
Setting up a pin using the pin names documented in the platform page should result in a correctly configured pin.
Actual behavior
Setting up a pin with the pin names documented in the platform page will configure a different pin.
NOTE: This is not a documentation error. The micro:bit pin naming is fixed and widely documented.
Steps to reproduce
-
Connect an analog sensor to the BBC micro:bit pin, marked
0
. -
Execute the following code:
#include "mbed.h" int main() { AnalogIn mySensor(p0); while (true) { printf("%f\r\n", mySensor.read()); } return 0; }
-
The code will fail to run because P0 refers to nrf51822 pin p0_0, which does not support Analog in.
-
Change the
AnalogIn
definition above to:AnalogIn mySensor(P0_3);
-
The micro:bit will now print values measured on pin 0.
** Suggested Fix **
The micro:bit DAL contains a file that has a map of nrf51822 pins to micro:bit pins. This mapping should be added to PinNames.h.