这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 嵌入式开发 » MCU » 关于ADS Heap的问题

共1条 1/1 1 跳转至

关于ADS Heap的问题

菜鸟
2005-02-26 01:30:20     打赏

各位大虾,我用ADS1.2作了个小程序来调一个LPC2292的板子,在主程序中如果使用malloc()函数,就会进入到software interrupt里,如果不加这个申请内存的函数就没有任何问题,谁知道是什么原因。下面是我用的启动代码:

;-------------------------------------------------------------------------- ; Standard definitions of Mode bits and Interrupt (I & F) flags in PSRs ;-------------------------------------------------------------------------- Mode_USR EQU 0x10 Mode_FIQ EQU 0x11 Mode_IRQ EQU 0x12 Mode_SVC EQU 0x13 Mode_ABT EQU 0x17 Mode_UND EQU 0x1B Mode_SYS EQU 0x1F

I_Bit EQU 0x80 ; when I bit is set, IRQ is disabled F_Bit EQU 0x40 ; when F bit is set, FIQ is disabled

;-------------------------------------------------------------------------- ;Definition of length of stack, which can be changed according to the requirement ;-------------------------------------------------------------------------- UND_STACK_LEGTH EQU 0 ABT_STACK_LEGTH EQU 0 FIQ_STACK_LEGTH EQU 0 IRQ_STACK_LEGTH EQU 512 SVC_STACK_LEGTH EQU 256 SYS_STACK_LEGTH EQU 256

;-------------------------------------------------------------------------- ; Add lengths >0 for FIQ_Stack, ABT_Stack, UND_Stack,SVC_STACK if you need them. ; Offsets will be loaded as immediate values. ; Offsets must be 8 byte aligned. ;-------------------------------------------------------------------------- Offset_StackUnd EQU 0 Offset_StackAbt EQU Offset_StackUnd + UND_STACK_LEGTH Offset_StackFiq EQU Offset_StackAbt + ABT_STACK_LEGTH Offset_StackIrq EQU Offset_StackFiq + FIQ_STACK_LEGTH Offset_StackSvc EQU Offset_StackIrq + IRQ_STACK_LEGTH Offset_StackSys EQU Offset_StackSvc + SVC_STACK_LEGTH

;-------------------------------------------------------------------------- ; Declaration of Import Labels ;-------------------------------------------------------------------------- IMPORT __main ;C main subroutine entry IMPORT Vectors ;In file Vectors.s IMPORT top_of_stacks ;In file Stack.s IMPORT bottom_of_stacks ;In file Stack.s IMPORT bottom_of_heap ;In file heap.s IMPORT InitLPC2000 ;In file target.c IMPORT InitBoard ;In file target.c ;-------------------------------------------------------------------------- ; Declaration of Export Labels ;-------------------------------------------------------------------------- EXPORT Reset EXPORT __rt_div0 EXPORT __user_initial_stackheap

;-------------------------------------------------------------------------- ;Reset handle entry ;-------------------------------------------------------------------------- CODE32 AREA Init,CODE,ALIGN=4,READONLY Reset BL InitLPC2000 ; LPC2000 mcu chip initialization BL InitBoard ; Initialize the target board BL InitStack ; initialize stack NOP B __main ; Jump to the entry point of C program

;-------------------------------------------------------------------------- ;Function: InitStack ;Description: Initialize stack pointer registers ;-------------------------------------------------------------------------- InitStack

LDR r0, =top_of_stacks ;-------------------------------------------------------------------------- ;Config stack of Undefined mode ;-------------------------------------------------------------------------- MSR CPSR_c, #Mode_UND:OR:I_Bit:OR:F_Bit ;No interrupts SUB sp, r0, #Offset_StackUnd ;-------------------------------------------------------------------------- ;Config stack of Abort mode ;-------------------------------------------------------------------------- MSR CPSR_c, #Mode_ABT:OR:I_Bit:OR:F_Bit ;No interrupts SUB sp, r0, #Offset_StackAbt ;-------------------------------------------------------------------------- ;Config stack of FIQ mode ;-------------------------------------------------------------------------- MSR CPSR_c, #Mode_FIQ:OR:I_Bit:OR:F_Bit ;No interrupts SUB sp, r0, #Offset_StackFiq ;-------------------------------------------------------------------------- ;Config stack of IRQ mode ;-------------------------------------------------------------------------- MSR CPSR_c, #Mode_IRQ:OR:I_Bit:OR:F_Bit ;No interrupts SUB sp, r0, #Offset_StackIrq ;-------------------------------------------------------------------------- ;Config stack of SVC mode ;-------------------------------------------------------------------------- MSR CPSR_c, #Mode_SVC:OR:I_Bit:OR:F_Bit ;No interrupts SUB sp, r0, #Offset_StackSvc ;-------------------------------------------------------------------------- ;Config stack of SYS mode ;-------------------------------------------------------------------------- MSR CPSR_c, #Mode_SYS SUB sp, r0, #Offset_StackSys

MOV PC, lr ;return

;-------------------------------------------------------------------------- ;Function: __user_initial_stackheap ;Description: Initialize heap for libraries. ; It is necessary for C/C++ function, ; so you'd better not delete the subroutine. ;-------------------------------------------------------------------------- __user_initial_stackheap LDR r0,=bottom_of_heap MOV pc,lr

;-------------------------------------------------------------------------- ;Function: __rt_div0 ;Description:Handle the error of dividing by zero ,which can be added ; according the application ;-------------------------------------------------------------------------- __rt_div0 B __rt_div0

END ;/************************************************************************ ; End Of File ;************************************************************************/




关键词: 关于     问题     -------------------    

共1条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]