Jump to content
43oh

ISRs vector table on GNU asm


Recommended Posts

Hi,

I have problem with nvic vector table for stellaris lm4f120.

 

here is my little asm code:

 

asm file:

 

.equ STACK_START,  0x20001000
 
.section .vectors
 
.align 4
 
.word STACK_START
.word _start + 1 // add 1 for thumb mode
 
linker script:
MEMORY
{
    FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x00040000
    SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00008000
}
 
SECTIONS
{
    .text :
    {
        _text = .;
        KEEP(*(.vectors))
        *(.text*)
        *(.rodata*)
        _etext = .;
    } > FLASH
 
    .data : AT(ADDR(.text) + SIZEOF(.text))
    {
        _data = .;
        *(vtable)
        *(.data*)
        _edata = .;
    } > SRAM
 
    .bss :
    {
        _bss = .;
        *(.bss*)
        *(COMMON)
        _ebss = .;
    } > SRAM
}
 
 
compile options:
arm-none-eabi-as -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -o main.o main.s
arm-none-eabi-as -mthumb -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=softfp -o nvic.o nvic.s
arm-none-eabi-ld -T make.ld  --entry _start  --gc-sections -nostdlib -Map main.map -o main.elf main.o nvic.o
arm-none-eabi-objcopy -O binary main.elf main.bin
 
but, when i flashing my test application to flash rom, I see that programm counter is not correct and it = 0
 
please, help me write correct gcc assembler code for vector table.
 
 
Link to post
Share on other sites

On reset, VTABLE equals 0. This means the processor looks for the vector table beginning at memory address 0. You need a valid table there, so on powerup the processor knows where to go.

 

Put the address of a reset handler in flash address 4. It can load your new table on RAM and point VTABLE there. Any exceptions after that will look at your RAM table for handlers.

Link to post
Share on other sites

eternauta3k, thanks for your reply.

for example, I want to blink RGB diode, ie just enable RED( on LM4F120 LaunchPad Evaluation Board  pin  PIN_29 ( PF1 ) I want set to low ).

 

I do:

 

.global _blink_rgb_red

.type _blink_rgb_red, %function

 

_blink_rgb_red:

/* set PF1 as output */
mov r0, #0x02
ldr r1, =0x40025400
str r0,[r1]
 
/* set  PF1 data to 0 */
mov r0, #0
ldr r1, =0x40025000
str r0,[r1]
 
 
but it not working, because after boot program counter in not valid and it = 0 on startup while in flash address 4 offset is valid address.
 
here is my source code(attached).
 
Help me please, what am I doing wrong?
 
gdb session:
(gdb) target remote localhost:7777
Remote debugging using localhost:7777
0x00000000 in ?? ()
(gdb) x/xw 0
0x0: 0x20007fff
(gdb) x/xw 4
0x4: 0x000000e6
(gdb) info reg
r0             0x0 0
r1             0x0 0
r2             0x0 0
r3             0x0 0
r4             0x0 0
r5             0x0 0
r6             0x0 0
r7             0x0 0
r8             0x0 0
r9             0x0 0
r10            0x0 0
r11            0x0 0
r12            0x0 0
sp             0x20007fd8 0x20007fd8
lr             0xfffffff9 4294967289
pc             0x0 0x0
cpsr           0x20007fd8 536903640
 
 
 

src.zip

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...