2023-02-07 06:09 PM
Are there register programming references for specific boards?
Its really confusing when there are a whole bunch of "STM32" cpus, that i would think should share common register offsets, but STM32F4 has completely different offsets from STM32L4, for example.
(I'm mostly interested in the GPIO, for led and button)
So far, the best I've been able to do, is try to reverse-engineer the combined headers.
But there are so many layers, its confusing.
I'm trying to write assembly, so using the headers as-is, is not possible.
My specific products of interest are
Solved! Go to Solution.
2023-02-08 09:58 AM
> Might anyone have suggestions what I'm doing wrong?
May I suggest a way how do you find it out yourself? Try to run this under debugger, and read out and check/post relevant registers' content.
JW
PS How do you do the vector table? Is stack pointer OK?
2023-02-08 10:01 AM
Also, one wonders, how exactly do you distinguish between "works" and "not works", and whether you are aware of bouncy buttons.
JW
2023-02-08 01:45 PM
button_led_reflect:
ldr r3, =GPIOC_IDR // has addr
ldr r0, [r3] // has contents
and r0, #GPIO_PIN13 // mask PC15
ldr r3, =GPIOA_ODR // has addr
ldr r1, [r3] // has contents
bic r1, #GPIO_PIN5 // clear PA5
lsr r0, #13-5 // reposition bit
orr r1, r0 // PC13 -> PA5
str r1, [r3] // write content to ODR
bx lr
2023-02-08 04:23 PM
fancy!
but my code works as is :)
Its a "light while pressed", not a toggle.
buttoncheck:
ldr r0, =GPIOC_IDR
ldr r1, [r0]
and r1, #GPIO_PIN13
cmp r1, #0
bne buttoncheck
bl asm_led_toggle
button2:
ldr r0, =GPIOC_IDR
ldr r1, [r0]
and r1, #GPIO_PIN13
cmp r1, #0
beq button2
bl asm_led_toggle
b buttoncheck
I guess I could have made it shorter, replacing the cmp & beq, with
cbz r1, button2
and so on