Simon Wright
Simon Wright

Reputation: 25501

Button B on micro:bit always pushed

I’m programming a micro:bit (in Ada) at the bare-metal level, that is, I’m addressing the nrf51 registers directly.

I have no trouble with button A, GPIO pin 17: it’s configured as

dir => input, 
input => connect,
pull => pullup,
drive => s0s1, 
sense => disabled

and when the button is pressed the IN register bit 17 is low, when released it’s high.

However, with button B, GPIO pin 26, configured exactly the same, IN register bit 26 is always low.

The factory image recognises both button A and B.

Button B is correctly connected to edge connector pin 11 (checked voltage level at edge connector with DVM).

I’d like to know why I have to specify pullup, though, given that there’s already a 10k pull-up resistor on the board (and the DVM shows proper logic levels).

The schematic is here, the nRF51 reference manual is here.

I found an earlier schematic where GPIO pin 26 was shared with the magnetometer, could that be related?

Upvotes: 3

Views: 177

Answers (1)

Simon Wright
Simon Wright

Reputation: 25501

Turns out that

  • I use RTC1 to simulate the missing SysTick
  • RTC1 uses the low-frequency clock
  • I set up the low-frequency clock as if it’s running off a crystal (which it is not!) This means that pin 26’s GPIO functionality is taken over by the expected 32,768 kHz crystal input, so the GPIO is disconnected from it.

Cure: set up the low-frequency clock to run off the 32,768 kHz synthesized output from the high frequency clock.

Upvotes: 5

Related Questions