cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 gpio help

zener_1134
Associate
Posted on July 28, 2016 at 21:19

I'm new to arm programming, I'm teaching myself with the STM32 specifically the STM32F030x6.

To start myself off with any new mcu arch, I write a simple as ever code that would make one of the gpio pins go high to confirm it's working.

Though trying the following code doesn't seem to work, any ideas?


.text
start:
 ldr r1, RCC
 ldr r2, AHB
 str r2, [r1,#0x14]
 ldr r1, GPIOA
 ldr r2, MODER
 ldr r3, ODR
 str r2, [r1,#0x0]
 str r3, [r1,#0x14]
stop: b stop
.align
RCC: .word 0x40021000
AHB: .word 0x00020000
GPIOA: .word 0x48000000
MODER: .word 0x00000005
ODR: .word 0x00000003

I'm using the stlinkV2 if that helps.

Edit: forgot mention I'm using the gnu assembler #stm32-gpio
3 REPLIES 3
Radosław
Senior II
Posted on July 28, 2016 at 22:14

1. Why assembler? At  this day is ways of time.  need to be maniac to use asembler on Cortex.

2. Read  erratas. 1 for core, second for chosen MCU.

After enabling peripheral clock you need to wait before acces to this peripheral registers.

Dummy read from RCC will be correct (more precise than this in errata).

There is a restriction for LDR STR in errata,....

zener_1134
Associate
Posted on July 28, 2016 at 22:45

I don't plan on using assembly for major projects. I use asm as a way to introduce myself to new chips to better understand the arch and have the knowledge to deal with any optimization issues I might come across.

And thanks for the info I'll look into the errata
Radosław
Senior II
Posted on July 28, 2016 at 22:50

Most off cortex M programist don't have any knowlege about architecture and they have many success in this matter.

In C but clean C not in libraries like SPL or HAL, you will enought learn architecture.