VTOR setting in startup code

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

VTOR setting in startup code

Jump to solution
2,101 Views
biafra
Senior Contributor I

Hi everyone,

I use MCUXpresso SDK: I noticed that in the startup code for all the compilers other than MCUXpresso, there is the code for setting VTOR register before the call of the SystemInit function, but there isn't such code for MCUXpresso compiler.

For ARM:

LDR R0, =0xE000ED08
LDR R1, =__Vectors
STR R1, [R0]
LDR R2, [R1]
MSR MSP, R2

For GCC:

.equ VTOR, 0xE000ED08
ldr r0, =VTOR
ldr r1, =__isr_vector
str r1, [r0]
ldr r2, [r1]
msr msp, r2

For IAR:

LDR R0, =0xE000ED08
LDR R1, =__vector_table
STR R1, [R0]
LDR R2, [R1]
MSR MSP, R2

What is the reason for this choice?

How can I set the VTOR register?

Many thanks

Biafra

1 Solution
1,790 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Francesco Bianchini 

As long as MCUXpresso IDE uses a GCC compiler, if you want to set VTOR register you could use the same code that you mentioned, you will only have to specify that you going to uses assembly code.

Hope this helps

Best Regards

Jorge Alcala

View solution in original post

1 Reply
1,791 Views
jorge_a_vazquez
NXP Employee
NXP Employee

Hi Francesco Bianchini 

As long as MCUXpresso IDE uses a GCC compiler, if you want to set VTOR register you could use the same code that you mentioned, you will only have to specify that you going to uses assembly code.

Hope this helps

Best Regards

Jorge Alcala