Code: Select all
bl(foo) # jump to subroutine, return address goes into r14
...
label(foo)
add(r0, r0, r0) # do something
mov(pc, r14) # return
Code: Select all
bl(foo) # jump to subroutine, return address goes into r14
...
label(foo)
add(r0, r0, r0) # do something
mov(pc, r14) # return
Code: Select all
from pyb import Timer, Pin
import stm
# Waggle pin A2 (aka X3) on then off.
# A timer callback receives the timer obj as a parameter which is not used here.
@micropython.asm_thumb
def asm_pin_waggle(r0):
movwt(r1, stm.GPIOA) # Port A
movw(r2, 1<<2) # A2
strh(r2, [r1, stm.GPIO_BSRRL]) # Set high...
strh(r2, [r1, stm.GPIO_BSRRH]) # then set low.
# Configure pin X3 (aka A2)
PinX3 = Pin(Pin.board.X3, Pin.OUT_PP)
# Setup a 100us 50:50 PWM on pin X2.
tim2 = Timer(2,prescaler=83,period=99,mode=Timer.DOWN)
ch2 = tim2.channel(2,Timer.PWM,pin=Pin('X2'))
ch2.pulse_width_percent(50)
# Have an ISR written in assembler called.
ch2.callback(asm_pin_waggle)
Code: Select all
# Return the address of an array (to put in another array)
@micropython.asm_thumb
def getaddress(r0):
nop()