Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cortex-M3 Initialisation

I wrote (IMO) almost simpliest ARM application and it didn't work :) What could be wrong? What is missed?

After flash write and CPU reset there are garbage in registers.

Please, be kind and if U know, tell me what has to be done to run simplest application on STM32F1.

May be someone coud enumerate what has to be done before application starts, ie.

  1. Initialize stack (it is necessary?)
  2. Set something.
  3. Set something else.

The application:

@Directives
    .thumb                  @.code 16
    .syntax unified

.section .text
    .org 0                  @ Alters location of pointer - in this case set to zero

vectors:                    @ Define basic vectors for specific capabilities
    .word _start + 1        @ Set - start address and increment pointer
    .word _nmi_handler + 1  @ Below all other vectors will be declared:
    .word _hard_fault + 1
    .word _memory_fault + 1
    .word _bus_fault + 1
    .word _usage_fault + 1

_start:
    mov r0, #5
    mov r1, #4
    add r2, r0, r1

_nmi_handler:
_hard_fault:
_memory_fault:
_bus_fault:
_usage_fault:

Maybe someone know any tutorials or books, about linker scripts, cpu initialisation etc.?

The processor is: STM32F103VBT6

Programmed by: OpenOCD.

Thanks in advance.

like image 455
Tyrreus Avatar asked Dec 06 '22 16:12

Tyrreus


1 Answers

From the M3 documentation;

The vector table at location 0 is only required to have four values:

Stack top address
Reset routine location
NMI ISR location
Hard Fault ISR location.

The stack top address should be at address 0, seems you're missing it.

like image 52
Joachim Isaksson Avatar answered Dec 28 '22 07:12

Joachim Isaksson