cancel
Showing results for 
Search instead for 
Did you mean: 

Detailed programming reference for specific boards?

PhilBrown
Associate II

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

  • Nucleo-ST32F401RE
  • Nucleo-ST32L476 (VG?)

13 REPLIES 13

> 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?

Also, one wonders, how exactly do you distinguish between "works" and "not works", and whether you are aware of bouncy buttons.

JW

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 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

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