arm thumb2 assembly

Questions and discussion about running MicroPython on a micro:bit board.
Target audience: MicroPython users with a micro:bit.
Post Reply
rhubarbdog
Posts: 85
Joined: Tue Nov 07, 2017 11:45 pm

arm thumb2 assembly

Post by rhubarbdog » Mon Aug 20, 2018 4:17 am

Has any one got examples of using the arm thumb2 assembly language.
In particular i want to have a function that takes a pin and a bytearray as parameters.
in a while loop until a terminal condition is met the code is

Code: Select all

index=0
while not Terminal_Condition:
  x=pinX.read_digital()
  storage[index]=x
  index+=1
Any digital sensors that use a 1 wire protocol to transmit their data can't be used on the microbit, micropython just runs too slow. I've looked on github and someone has written an extension to microbit micropython to handle bit banging. It's just never been accepted.
I thought writing a bit bang function in assembler may be the answer it's just there's a lack of examples out there.

thanks

shaoziyang
Posts: 238
Joined: Sun Apr 17, 2016 1:55 pm

Re: arm thumb2 assembly

Post by shaoziyang » Mon Aug 20, 2018 7:47 am

Code: Select all

from microbit import *

display.show('S')

def get_serial_number(type=hex):
    NRF_FICR_BASE = 0x10000000
    DEVICEID_INDEX = 25 # deviceid[1]

    @micropython.asm_thumb
    def reg_read(r0):
        ldr(r0, [r0, 0])
    return type(reg_read(NRF_FICR_BASE + (DEVICEID_INDEX*4)))
    
while True:
    if button_a.was_pressed():
        display.scroll(get_serial_number())
        sleep(1000)
        display.show('S')
        
    sleep(100)

User avatar
dhylands
Posts: 2956
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: arm thumb2 assembly

Post by dhylands » Mon Aug 20, 2018 5:18 pm

I have an example here: https://github.com/dhylands/bioloid3/bl ... rt_port.py (the _write_packet routine).

User avatar
pythoncoder
Posts: 3161
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: arm thumb2 assembly

Post by pythoncoder » Tue Aug 21, 2018 8:51 am

Peter Hinch

Post Reply