Dear all,
I just begin with micropython. For instant, I use STM32F4 discovery board. Thanks a lot to micropython team! This is a very great tool!
I would like to play the stm class in order to get access to the MCU registers.
I see some examples in th micropython doc. But these example use inline assembler.
Is it possible to use this class without inline assembler?
I have try the following lines in REPL without success!
--- my input
GPIOD_BaseAdr=stm.GPIOD
GPIOD_BSRRL_Adr=stm.GPIO_BSRRL+GPIOD_BaseAdr
-- my output
No error but I don't know the effect!
Thanks in advance for comments and suggestions
Best regards
Questions about stm class
Re: Questions about stm class
stm.GPIOD is a numeric constant containing the address of the GPIOD register, stm.GPIO_BSRRL is a numeric constant containing the offset of the BSSRL register within the GPIO peripheral.
To actually modify the register you need to use the stm.mem8, mem16, or mem32 commands.
Something like: should set D0 and
should clear D0.
To actually modify the register you need to use the stm.mem8, mem16, or mem32 commands.
Something like:
Code: Select all
import stm
stm.mem16(stm.GPIOD + stm.GPIO_BSRRL, 1)
Code: Select all
import stm
stm.mem16(stm.GPIOD + stm.GPIO_BSRRH, 1)
-
- Posts: 24
- Joined: Mon Apr 27, 2015 8:25 am
Re: Questions about stm class
Thanks very much!
I will adopt micropython for my courses! Having high level and low level approach is very nice for teaching.
Thanks again.
I will adopt micropython for my courses! Having high level and low level approach is very nice for teaching.
Thanks again.
Re: Questions about stm class
Actually, you need to use the mem8, mem16 and mem32 functions like an array:
Code: Select all
import stm
stm.mem16[stm.GPIOD + stm.GPIO_BSRRL] = 1 # set D0 high
stm.mem16[stm.GPIOD + stm.GPIO_BSRRH] = 1 # set D0 low
dport = stm.mem32[stm.GPIOD + stm.GPIO_IDR] # read all 16 bits on port D