Accessing the row pins for LED display

Questions and discussion about running MicroPython on a micro:bit board.
Target audience: MicroPython users with a micro:bit.
Post Reply
kjw
Posts: 10
Joined: Wed Jun 17, 2020 11:34 am

Accessing the row pins for LED display

Post by kjw » Wed Jun 17, 2020 11:40 am

Is it possible to access the pins for the rows of the LED display to allow direct, low-level control of the LED screen after a display_off(), of course? The columns appear to be available as microbit.pinX but I've not worked out how to access the rows.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Accessing the row pins for LED display

Post by jimmo » Mon Jun 29, 2020 7:10 am

kjw wrote:
Wed Jun 17, 2020 11:40 am
The columns appear to be available as microbit.pinX but I've not worked out how to access the rows.
My understanding is that the column pins are available because they are also shared with the edge connector.

If you want to access the row pins you can do so via machine.mem32 to read and write the pin registers directly... (not fun, but also once you've got it working it's very simple).

e.g. this does pin 13, but you can look up the nrf51822 reference manual for the other addresses and bits to set for the row pins (although you might also have to set the pin mode).

Code: Select all

    # pin13 = 1
    machine.mem8[0x5000050a] |= 0b10000000
    # pin13 = 0
    machine.mem8[0x5000050e] |= 0b10000000

kjw
Posts: 10
Joined: Wed Jun 17, 2020 11:34 am

Re: Accessing the row pins for LED display

Post by kjw » Thu Aug 06, 2020 7:10 pm

Thanks for the info. It reminds me of the days of peek and poke!

kjw
Posts: 10
Joined: Wed Jun 17, 2020 11:34 am

Re: Accessing the row pins for LED display

Post by kjw » Sat May 28, 2022 5:16 pm

On a V1 micro:bit I had some success with this for driving directly one physical row (2nd one from top).

Code: Select all

MicroPython v1.9.2-34-gd64154c73 on 2017-09-01; micro:bit v1.0.1 with nRF51822
Type "help()" for more information.
>>>
>>> import machine
>>> import microbit
>>> display.off()
>>> OUTSET = 0x50000508
>>> OUTCLR = 0x5000050c
>>> OUT = 0x50000504
>>> machine.mem32[OUTSET] = 0b1000000000000000  # turn on ROW3
>>> machine.mem32[OUTCLR] = 0b0110000000000000  # turn off ROW1 ROW2
>>> machine.mem32[OUTCLR] = 0b0001111111110000  # all LED on
>>> machine.mem32[OUTSET] = 0b0001000001110000  # clear LEDs not in physical row
>>> machine.mem32[OUT] = machine.mem32[OUT] & 0xfffff07f | (0b11111 << 7) # off
>>> machine.mem32[OUT] = machine.mem32[OUT] & 0xfffff07f | (0b00000 << 7) # on
I realise this all changes on V2 with the 5x5 electrical layout rather than the 3x9.

Post Reply