We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Vectors LDR PC, Reset_Addr LDR PC, Undef_Addr LDR PC, SWI_Addr LDR PC, PAbt_Addr LDR PC, DAbt_Addr NOP ; Reserved Vector LDR PC, IRQ_Addr
LDR PC, [PC, #-0x0120] ; Vector
from VicVectAddr
LDR PC, FIQ_Addr
Reset_Addr DCD Reset_Handler
Undef_Addr DCD Undef_Handler
SWI_Addr DCD 0 PAbt_Addr DCD PAbt_Handler
DAbt_Addr DCD DAbt_Handler
DCD 0 ; Reserved Address
IRQ_Addr DCD 0
FIQ_Addr DCD FIQ_Handler
Undef_Handler B Undef_Handler
SWI_Handler B SWI_Handler
PAbt_Handler B PAbt_Handler
DAbt_Handler B DAbt_Handler
;IRQ_Handler B IRQ_Handler
FIQ_Handler B FIQ_Handler
; Reset Handler
EXPORT Reset_Handler
Reset_Handler
; Setup Stack for each mode
LDR R0, =Stack_Top
; Enter Undefined Instruction Mode and set its Stack
Pointer
MSR CPSR_c,
#Mode_UND:OR:I_Bit:OR:F_Bit
MOV SP, R0
SUB R0, R0, #UND_Stack_Size
; Enter Abort Mode and set its Stack Pointer
#Mode_ABT:OR:I_Bit:OR:F_Bit
SUB R0, R0, #ABT_Stack_Size
; Enter FIQ Mode and set its Stack Pointer
#Mode_FIQ:OR:I_Bit:OR:F_Bit
SUB R0, R0, #FIQ_Stack_Size
; Enter IRQ Mode and set its Stack Pointer
#Mode_IRQ:OR:I_Bit:OR:F_Bit
SUB R0, R0, #IRQ_Stack_Size
; Enter Supervisor Mode and set its Stack Pointer
#Mode_SVC:OR:I_Bit:OR:F_Bit
SUB R0, R0, #SVC_Stack_Size
; Enter User Mode and set its Stack Pointer
MSR CPSR_c, #Mode_USR
SUB SL, SP, #USR_Stack_Size
; IMPORT TargetResetInit
; BL TargetResetInit
; Enter the C code
IMPORT __main
LDR R0, =__main
BX R0
; User Initial Stack & Heap
AREA |.text|, CODE, READONLY
IMPORT __use_two_region_memory
EXPORT __user_initial_stackheap __user_initial_stackheap
LDR R0, = Heap_Mem
LDR R1, =(Stack_Mem +
USR_Stack_Size)
LDR R2, = (Heap_Mem +
Heap_Size)
LDR R3, = Stack_Mem
BX LR
END
This is my Startup code. While debugging the execution stuck at "Enter the C Code part" Instead of jump to main,program execution enter to below loop
0x0000012C E2522010 SUBS R2,R2,#0x00000010 0x00000130 28A10078 STMCSIA R1!,{R3-R6} 0x00000134 8AFFFFFC BHI 0x0000012C
I cant see the corresponding C code of this loop. Plz give some suggestions or solution to this problem
report using the proper tags.
Vectors LDR PC, Reset_Addr LDR PC, Undef_Addr LDR PC, SWI_Addr LDR PC, PAbt_Addr LDR PC, DAbt_Addr NOP ; Reserved Vector LDR PC, IRQ_Addr LDR PC, [PC, #-0x0120] ; Vector from VicVectAddr LDR PC, FIQ_Addr Reset_Addr DCD Reset_Handler Undef_Addr DCD Undef_Handler SWI_Addr DCD 0 PAbt_Addr DCD PAbt_Handler DAbt_Addr DCD DAbt_Handler DCD 0 ; Reserved Address IRQ_Addr DCD 0 FIQ_Addr DCD FIQ_Handler Undef_Handler B Undef_Handler SWI_Handler B SWI_Handler PAbt_Handler B PAbt_Handler DAbt_Handler B DAbt_Handler ;IRQ_Handler B IRQ_Handler FIQ_Handler B FIQ_Handler ; Reset Handler EXPORT Reset_Handler Reset_Handler ; Setup Stack for each mode LDR R0, =Stack_Top ; Enter Undefined Instruction Mode and set its Stack Pointer MSR CPSR_c, #Mode_UND:OR:I_Bit:OR:F_Bit MOV SP, R0 SUB R0, R0, #UND_Stack_Size ; Enter Abort Mode and set its Stack Pointer MSR CPSR_c, #Mode_ABT:OR:I_Bit:OR:F_Bit MOV SP, R0 SUB R0, R0, #ABT_Stack_Size ; Enter FIQ Mode and set its Stack Pointer MSR CPSR_c, #Mode_FIQ:OR:I_Bit:OR:F_Bit MOV SP, R0 SUB R0, R0, #FIQ_Stack_Size ; Enter IRQ Mode and set its Stack Pointer MSR CPSR_c, #Mode_IRQ:OR:I_Bit:OR:F_Bit MOV SP, R0 SUB R0, R0, #IRQ_Stack_Size ; Enter Supervisor Mode and set its Stack Pointer MSR CPSR_c, #Mode_SVC:OR:I_Bit:OR:F_Bit MOV SP, R0 SUB R0, R0, #SVC_Stack_Size ; Enter User Mode and set its Stack Pointer MSR CPSR_c, #Mode_USR MOV SP, R0 SUB SL, SP, #USR_Stack_Size ; IMPORT TargetResetInit ; BL TargetResetInit ; Enter the C code IMPORT __main LDR R0, =__main BX R0 ; User Initial Stack & Heap AREA |.text|, CODE, READONLY IMPORT __use_two_region_memory EXPORT __user_initial_stackheap __user_initial_stackheap LDR R0, = Heap_Mem LDR R1, =(Stack_Mem + USR_Stack_Size) LDR R2, = (Heap_Mem + Heap_Size) LDR R3, = Stack_Mem BX LR END
While debugging the execution stuck at "BX R0" and instead of jump to main,program execution enter to below loop.
What will be the problem. Plz give some suggestions or solution to this problem
While debugging the execution stuck at "BX R0"
I can't seem to find "BX R0" in the code you posted.
Oh, there it is. Sorry, must have made a mistake using the search function.
While debugging the execution stuck at "BX R0" and instead of jump to main,program execution enter to below loop. ... What will be the problem.
Why do you think there is a problem? Did you expected that the instruction "BX R0" would jump to main()? Actually, this instruction jumps into standard library initialization code which initializes static variables, stack and heap, and then jumps to main(). The loop you are referring to is zeroing code: uninitialized static variables are filled with zeros prior to main(). If program flow doesn't reach main() eventually, then you have a problem...
Just out of curiosity, what does main() look like?
Vectors LDR PC, Reset_Addr LDR PC, Undef_Addr LDR PC, SWI_Addr LDR PC, PAbt_Addr LDR PC, DAbt_Addr NOP ; Reserved Vector LDR PC, IRQ_Addr LDR PC, [PC, #-0x0120] ; Vector from VicVectAddr LDR PC, FIQ_Addr
Please check the red marked codes, you should have 8 exception vectors, but looks like you have 9.
If it is not reaching main() what might be the problem
In our case it is going back to begining of startup code
While debugging the execution restart from start up at
0x00005458 DFAB SWI 0xAB
What will be the reason?
Thank you
http://www.keil.com/forum/docs/thread7666.asp
Did you read John Linqs post? There should only be 8 interrupt vectors, not 9.
Right now, you seem to have to handlers for the normal IRQ. One with a hard-coded handler, and one using the Vic vector lookup.
Remove the line with the IRQ_Addr handler, or change it to:
; LDR PC, IRQ_Addr