not logged in | [Login]
Both the store and load memory functions require two parameters to define an address - a base address (register) and offset ... there are many useful static definitions in the uPy stm module for example; stm.GPIOA is the base/starting-address of the chunk of memory that references the GPIOA interface (General Purpose Input Output A) and there are many offsets in the form stm.GPIO_xxxx definitions (e.g. stm.GPIO_OSPEEDR - the output speed register) that, when combined with (added to) the base GPIOx address identify the relevant memory cell.
stm.GPIOA+stm.GPIO_OSPEEDR = the address of GPIOA's Output Speed Register stm.GPIOB+stm.GPIO_OSPEEDR = the address of GPIOB's Output Speed Register
#put the passed in value in r0 into Timer 2's Control Register #who's address = stm.TIM2 + stm.TIM_CR1 @micropython.asm_thumb def set_random_value(r0): movwt(r1, stm.TIM2) str(r0, [r1, stm.TIM_CR1)
str(regA, [regB, offset]) put content of regA into address [regB, offset]
strb(regA, [regB, offset])
strh(regA, [regB, offset]) store half-word into the address indicated by value in register + offset e.g. `strh(r1, [r0, stm.GPIO_BSRRL])
Offsets are measured in bytes.
Last edited by Peter Hinch, 2015-04-20 12:12:45