⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 init.s

📁 利用ADS1.2开发的S3C2410平台下步进电机程序
💻 S
📖 第 1 页 / 共 2 页
字号:
    LDRCC  r2, [r0], #4                    ;// Get value from ROM
    STRCC  r2, [r1], #4                    ;// Put value in RAM
    BCC    INT_ROM_Vars_Copy               ;// Continue

INT_BSS_Clear
    LDR    r1,BSS_End_Ptr                  ;// Pickup the end of the BSS area
    MOV    r2,#0                           ;// Clear value in r2

INT_BSS_Clear_Loop
    CMP    r3,r1                           ;// Are the start and end equal?
    STRCC  r2,[r3],#4                      ;// Clear a word
    BCC    INT_BSS_Clear_Loop              ;// If so, continue with BSS clear


;/*
;***************************************************************************************************
;*								Initialize the system stack pointers
;*											初始化堆栈
;*
;***************************************************************************************************
;*/    
;// 初始化Sys模式下的堆栈 
	LDR		SP,=SYS_STACK

;// 初始化IRQ模式下的堆栈   
    MRS    	r0,CPSR                         	;// Pickup current CPSR
    BIC    	r0,r0,#MODE_MASK                	;// Clear the mode bits
    ORR    	r0,r0,#MODE_IRQ                 	;// Set the IRQ mode bits
    MSR    	CPSR_cxsf,r0                    	;// Move to IRQ mode                                	
	LDR		SP,=IRQ_STACK                         	;// Setup IRQ stack pointer
;// 初始化SUP模式下的堆栈   
    MRS    	r0,CPSR                         	;// Pickup current CPSR
    BIC    	r0,r0,#MODE_MASK                	;// Clear the mode bits
    ORR    	r0,r0,#MODE_SUP               	;// Set the SUP mode bits
    MSR    	CPSR_cxsf,r0                    	;// Move to SUP mode                                	
	LDR		SP,=SVC_STACK                         	;// Setup SUP stack pointer
;// 转回系统模式,并使能中断标志位    
    MRS    	r0,CPSR                         	;// Pickup current CPSR
    BIC    	r0,r0,#MODE_MASK                	;// Clear mode bits
    ORR    	r0,r0,#MODE_SYS                 	;// Set the SYSTEM mode bits    
    BIC		R0,R0,#INTLOCK						;// 开中断    
    MSR     CPSR_cxsf,r0                    	;// All interrupt stacks are setup,
                                           		;// return to supervisor mode
                           		
    
                                           	                                           	
;/*
;***************************************************************************************************
;									  C语言的调用(跳至应用程序)                       
;***************************************************************************************************
;*/	

	IMPORT		C_Entry
	B			C_Entry ;C_Entry是一个循环程序


;/*
;***************************************************************************************************
;*												INT_IRQ
;*
;***************************************************************************************************
;*/
  
    AREA IRQ,CODE,READONLY
    EXPORT  INT_IRQ
INT_IRQ
;/* This Code is used to correctly handle interrupts and
;   is necessary due to the nature of the ARM7 architecture  */
    STMDB   sp!, {r1}   ;保存寄存器r1,将r1压栈
    MRS     r1, SPSR
    TST     r1, #I_BIT
    LDMIA   sp!, {r1}
    SUBNES  pc,lr,#4


;//LR_IRQ,SPSR_IRQ压栈来避免下一次中断发生使它们被冲掉
  SUB	lr, lr, #4
  STMFD	sp!, {lr} 
  MRS	r14, SPSR
  STMFD	sp!, {r0-r4, r14}
 ;// 查寄存器INTOFFSET找出对应的中断    
 	LDR		R0,=INTOFFSET
 	LDR		R0,[R0,#0]
 ;//判断是否有中断发生
 	LDR		R1,=INTPND
 	LDR		R1,[R1]
 	CMP		R1,#0X0
 	BNE		IRQ_VECTOR_FOUND
;// No bits in pending register set, restore context and exit interrupt servicing
    LDMIA	SP!,{R0-R4,R14}
    MSR		SPSR_csxf,R14
    LDMIA	SP!,{PC}^
;//清中断控制源
IRQ_VECTOR_FOUND
	;//清中断

	LDR     R1,=EINTPEND
	LDR     R3,[R1,#0]
	STR     R3,[R1,#0]
	LDR		R1,=SRCPND
	LDR		R3,[R1,#0]
	STR		R3,[R1,#0]
	LDR		R2,=INTPND
	LDR		R3,[R2,#0]      
	STR		R3,[R2,#0]

;// Get IRQ vector table address
    LDR     r3,=INT_IRQ_Vectors         ;// Get IRQ vector table address
    MOV     r2, r0, LSL #2              ;// Multiply vector by 4 to get offset into table
    ADD     r3, r3, r2                  ;// Adjust vector table address to correct offset
    LDR     r2, [r3,#0]                 ;// Load branch address from vector table
    MOV     PC, r2                      ;// Jump to correct branch location based on vector table

;/*
;***************************************************************************************************
;*										INT_TIMER2_Shell
;*
;***************************************************************************************************
;*/
	EXPORT INT_TIMER2_Shell
INT_TIMER2_Shell
    MRS     r1,CPSR                      ;// Pickup current CPSR
    BIC     r1,r1,#MODE_MASK             ;// Clear the mode bits
    ORR     r1,r1,#MODE_SYS              ;// Set the SYS mode bits
    ORR     r1,r1,#I_BIT				 ;//DISABLE INT
    MSR     CPSR_cxsf,r1                 ;// Change to IRQ mode 
    ;//跳至上下文保存处理程序
    STMDB SP!,{LR}
    ;//跳至中断服务程序
    ;LDR R0,=Handler_TIMER2
    BL      TIMER2_LISR                           ;//Processing
    ;//clear interrupt
    LDR     		R1,=EINTPEND
    LDR     		R3,[R1,#0]
    STR     		R3,[R1,#0]
    LDR		R1,=SRCPND
    LDR		R3,[R1,#0]
    STR		R3,[R1,#0]
    LDR		R2,=INTPND
    LDR		R3,[R2,#0]      
    STR		R3,[R2,#0]

    LDMIA       SP!,{LR}
    ;//返回到IRQ模式
     MRS     r1,CPSR                      ;// Pickup current CPSR
    BIC     r1,r1,#MODE_MASK             ;// Clear the mode bits
    ORR     r1,r1,#MODE_IRQ              ;// Set the IRQ mode bits
    BIC	    R1,R1,#I_BIT				;//ENABLE INT
    MSR     CPSR_cxsf,r1                 ;// Change to IRQ mode
    
 ;//此值是在进入IRQ时设置的   
    LDMIA	SP!,{R0-R4,R14}
    MSR		SPSR_csxf,R14
    LDMIA	SP!,{PC}^
;/*
;***************************************************************************************************
;*										INT_TIMER3_Shell
;*
;***************************************************************************************************
;*/
	EXPORT INT_TIMER3_Shell
INT_TIMER3_Shell
    MRS     r1,CPSR                      ;// Pickup current CPSR
    BIC     r1,r1,#MODE_MASK             ;// Clear the mode bits
    ORR     r1,r1,#MODE_SYS              ;// Set the SYS mode bits
    ORR     r1,r1,#I_BIT				 ;//DISABLE INT
    MSR     CPSR_cxsf,r1                 ;// Change to IRQ mode 
    ;//跳至上下文保存处理程序
    STMDB SP!,{LR}
    ;//跳至中断服务程序
    ;LDR R0,=Handler_TIMER3
    BL      TIMER3_LISR                           ;//Processing
    ;//clear interrupt
    LDR     		R1,=EINTPEND
    LDR     		R3,[R1,#0]
    STR     		R3,[R1,#0]
    LDR		R1,=SRCPND
    LDR		R3,[R1,#0]
    STR		R3,[R1,#0]
    LDR		R2,=INTPND
    LDR		R3,[R2,#0]      
    STR		R3,[R2,#0]

    LDMIA       SP!,{LR}
    ;//返回到IRQ模式
     MRS     r1,CPSR                      ;// Pickup current CPSR
    BIC     r1,r1,#MODE_MASK             ;// Clear the mode bits
    ORR     r1,r1,#MODE_IRQ              ;// Set the IRQ mode bits
    BIC	    R1,R1,#I_BIT				;//ENABLE INT
    MSR     CPSR_cxsf,r1                 ;// Change to IRQ mode
    
 ;//此值是在进入IRQ时设置的   
    LDMIA	SP!,{R0-R4,R14}
    MSR		SPSR_csxf,R14
    LDMIA	SP!,{PC}^
		
				
	END 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -