In boards/MicroBit/src/microbit-buttons.adb, function State, we have
if Button = Button_B then
-- For a reason that I don't understand right now, the B button is a
-- always detected as pressed (low). As far as I can see the code is
-- the same as button A and probing the hardware didn't show any
-- problem...
raise Program_Error with "Button B is not working...";
end if;
I believe I’ve found the reason: in microbit-time.adb, procedure Initialize, we have
Clocks.Set_Low_Freq_Source (Clocks.LFCLK_XTAL);
(weird, there isn’t a crystal attached to the low-frequency inputs at all; the only crystals on the board are 16 MHz, not the 32 kHz you’d need for the low frequency source), and this has the effect of what on STM chips would be called an alternate function on that pin, so that GPIO pin 26 is effectively disconnected.
Fix:
Clocks.Set_Low_Freq_Source (Clocks.LFCLK_SYNTH);
(the HF clock appears to run without needing any configuration).
In
boards/MicroBit/src/microbit-buttons.adb
, functionState
, we haveI believe I’ve found the reason: in
microbit-time.adb
, procedureInitialize
, we have(weird, there isn’t a crystal attached to the low-frequency inputs at all; the only crystals on the board are 16 MHz, not the 32 kHz you’d need for the low frequency source), and this has the effect of what on STM chips would be called an alternate function on that pin, so that GPIO pin 26 is effectively disconnected.
Fix:
(the HF clock appears to run without needing any configuration).