In pursuit of a temporary PWM fix, via embedded assembler, I am trying to push a 32bit number into GPIOA.GPIO_MODER address (trying, for test purposes, to implement PWM on pyb.LED(2) which, according to some comments in led.c, is on GPIOA 15 ... which seems to be born out by inspecting GPIOA.GPIO_ODR when switching it on and off) ... but the assembler interpreter doesn't like it;
Code: Select all
>>> @micropython.asm_thumb
... def alter():
... movwt(r0, stm.GPIOA)
... movwt(r1, 0x100aaa00)
... strh(r1, [r0, stm.GPIO_AFR1])
... movwt(r1, 0xa9600000)
... strh(r1, [r0, stm.GPIO_MODER])
...
SyntaxError: 'movwt' expects an integer
Code: Select all
>>> 0xa9600000<0xffffffff
True
>>> bin(0xa9600000)
'0b10101001011000000000000000000000'
>>> len(bin(0xa9600000)[2:])
32
Code: Select all
>>> len(bin(0x3fffffff)[2:])
30
>>> @micropython.asm_thumb
... def alter():
... movwt(r0, stm.GPIOA)
... movwt(r1, 0x100aaa00)
... strh(r1, [r0, stm.GPIO_AFR1])
... movwt(r1, 0x3fffffff)
... strh(r1, [r0, stm.GPIO_MODER])
...
>>> len(bin(0x3fffffff+1)[2:])
31
>>> @micropython.asm_thumb
... def alter():
... movwt(r0, stm.GPIOA)
... movwt(r1, 0x100aaa00)
... strh(r1, [r0, stm.GPIO_AFR1])
... movwt(r1, 0x3fffffff+1)
... strh(r1, [r0, stm.GPIO_MODER])
...
SyntaxError: 'movwt' expects an integer