导航: 老古网老古论坛XMOS公共讨论区XMOS开源项目区单片机程序设计嵌入式系统广告区域
→发表看法:[zhanghairong]问一个关于中断跳转表的问题



No.33687
作者:zhanghairong
邮件:tntdoder@hotmail.com
ID:103551
登陆:1次
文章数:1篇
最后登陆IP:222.240.10.58
最后登陆:2008/3/7 13:13:43
注册:2008/3/7 13:12:22
财富:105
发帖时间:2008/3/7 13:13:43
发贴者IP:222.240.10.58
标题:zhanghairong:问一个关于中断跳转表的问题
摘要:No.33687问一个关于中断跳转表的问题 问一个关于中断跳转表的问题 

我用仿真器+ads调试,程序是从0x30000000开始执行:
30000000    [0xea000074]   b        ResetHandler
30000004    [0xea000052]   b        HandlerUndef
30000008    [0xea000057]   b        HandlerSWI
3000000c    [0xea000062]   b        HandlerPabort
30000010    [0xea00005b]   b        HandlerDabort
30000014    [0xeafffffe]   b        0x30000014
30000018    [0xea000047]   b        HandlerIRQ
3000001c    [0xea000040]   b        HandlerFIQ
30000020    [0xea000008]   b        EnterPWDN
开始执行,我查看了地址0x000000处,如下:
00000000    [0xea00000a]   b        0x30
00000004    [0xeafffffe]   b        0x4
00000008    [0xeafffffe]   b        0x8
0000000c    [0xeafffffe]   b        0xc
00000010    [0xeafffffe]   b        0x10
00000014    [0xeafffffe]   b        0x14
00000018    [0xeafffffe]   b        0x18
0000001c    [0xeafffffe]   b        0x1c
当我触发中断后,发现中断的几个寄存器都有反应,但是程序跳到
00000018    [0xeafffffe]   b        0x18
就不动了,请问怎样才能正确的跳转到
30000018    [0xea000047]   b        HandlerIRQ


我的启动代码如下。


;=========================================
; NAME: 2440INIT.S
; DESC: C start up codes
;       Configure memory, ISR ,stacks
;    Initialize C-variables
; HISTORY:
; 2002.02.25:kwtark: ver 0.0
; 2002.03.20:purnnamu: Add some functions for testing STOP,Sleep mode
; 2003.03.14:DonGo: Modified for 2440.
;=========================================

    GET option.inc
    GET memcfg.inc
    GET 2440addr.inc

BIT_SELFREFRESH EQU    (1  <  <22)

;Pre-defined constants
USERMODE    EQU     0x10
FIQMODE     EQU     0x11
IRQMODE     EQU     0x12
SVCMODE     EQU     0x13
ABORTMODE   EQU     0x17
UNDEFMODE   EQU     0x1b
MODEMASK    EQU     0x1f
NOINT       EQU     0xc0

;The location of stacks
UserStack    EQU    (_STACK_BASEADDRESS-0x3800)    ;0x33ff4800 ~
SVCStack    EQU    (_STACK_BASEADDRESS-0x2800)    ;0x33ff5800 ~
UndefStack    EQU    (_STACK_BASEADDRESS-0x2400)    ;0x33ff5c00 ~
AbortStack    EQU    (_STACK_BASEADDRESS-0x2000)    ;0x33ff6000 ~
IRQStack    EQU    (_STACK_BASEADDRESS-0x1000)    ;0x33ff7000 ~
FIQStack    EQU    (_STACK_BASEADDRESS-0x0)    ;0x33ff8000 ~

;Check if tasm.exe(armasm -16 ...@ADS 1.0) is used.
    GBLL    THUMBCODE
    [ {CONFIG} = 16
THUMBCODE SETL  {TRUE}
        CODE32
         |
THUMBCODE SETL  {FALSE}
    ]

         MACRO
    MOV_PC_LR
         [ THUMBCODE
        bx lr
         |
        mov    pc,lr
         ]
    MEND

         MACRO
    MOVEQ_PC_LR
         [ THUMBCODE
        bxeq lr
         |
        moveq pc,lr
         ]
    MEND

         MACRO
$HandlerLabel HANDLER $HandleLabel

$HandlerLabel
    sub    sp,sp,#4    ;decrement sp(to store jump address)
    stmfd    sp!,{r0}    ;PUSH the work register to stack(lr does't push because it return to original address)
    ldr     r0,=$HandleLabel;load the address of HandleXXX to r0
    ldr     r0,[r0]     ;load the contents(service routine start address) of HandleXXX
    str     r0,[sp,#4]      ;store the contents(ISR) of HandleXXX to stack
    ldmfd   sp!,{r0,pc}     ;POP the work register and pc(jump to ISR)
    MEND


    IMPORT  |Image$$RO$$Limit|  ; End of ROM code (=start of ROM data)
    IMPORT  |Image$$RW$$Base|   ; Base of RAM to initialise
    IMPORT  |Image$$ZI$$Base|   ; Base and limit of area
    IMPORT  |Image$$ZI$$Limit|  ; to zero initialise

    IMPORT    MMU_SetAsyncBusMode

    AREA    Init,CODE,READONLY

    ENTRY

    ;1)The code, which converts to Big-endian, should be in little endian code.
    ;2)The following little endian code will be compiled in Big-Endian mode.
    ;  The code byte order should be changed as the memory bus width.
    ;3)The pseudo instruction,DCD can't be used here because the linker generates error.
    ASSERT    :DEF:ENDIAN_CHANGE
    [ ENDIAN_CHANGE
        ASSERT  :DEF:ENTRY_BUS_WIDTH
        ][ ENTRY_BUS_WIDTH=32
        b    ChangeBigEndian        ;DCD 0xea000007
        ]

        [ ENTRY_BUS_WIDTH=16
        andeq    r14,r7,r0,lsl #20   ;DCD 0x0007ea00
        ]

        [ ENTRY_BUS_WIDTH=8
        streq    r0,][r0,-r10,ror #1] ;DCD 0x070000ea
        ]
    |
        b    ResetHandler
    ]
    b    HandlerUndef    ;handler for Undefined mode
    b    HandlerSWI    ;handler for SWI interrupt
    b    HandlerPabort    ;handler for PAbort
    b    HandlerDabort    ;handler for DAbort
    b    .        ;reserved
    b    HandlerIRQ    ;handler for IRQ interrupt
    b    HandlerFIQ    ;handler for FIQ interrupt

;@0x20
    b    EnterPWDN    ; Must be @0x20.
ChangeBigEndian
;@0x24
    [ ENTRY_BUS_WIDTH=32
        DCD    0xee110f10    ;0xee110f10 =>   mrc p15,0,r0,c1,c0,0
        DCD    0xe3800080    ;0xe3800080 =>   orr r0,r0,#0x80;  //Big-endian
        DCD    0xee010f10    ;0xee010f10 =>   mcr p15,0,r0,c1,c0,0
    ]
    [ ENTRY_BUS_WIDTH=16
        DCD 0x0f10ee11
        DCD 0x0080e380
        DCD 0x0f10ee01
    ]
    [ ENTRY_BUS_WIDTH=8
        DCD 0x100f11ee
        DCD 0x800080e3
        DCD 0x100f01ee
    ]
    DCD 0xffffffff  ;swinv 0xffffff is similar with NOP and run well in both endian mode.
    DCD 0xffffffff
    DCD 0xffffffff
    DCD 0xffffffff
    DCD 0xffffffff
    b ResetHandler

;Function for entering power down mode
; 1. SDRAM should be in self-refresh mode.
; 2. All interrupt should be maksked for SDRAM/DRAM self-refresh.
; 3. LCD controller should be disabled for SDRAM/DRAM self-refresh.
; 4. The I-cache may have to be turned on.
; 5. The location of the following code may have not to be changed.

;void EnterPWDN(int CLKCON);
EnterPWDN
    mov r2,r0        ;r2=rCLKCON
    tst r0,#0x8        ;SLEEP mode?
    bne ENTER_SLEEP

ENTER_STOP
    ldr r0,=REFRESH
    ldr r3,[r0]        ;r3=rREFRESH
    mov r1, r3
    orr r1, r1, #BIT_SELFREFRESH
    str r1, [r0]        ;Enable SDRAM self-refresh

    mov r1,#16            ;wait until self-refresh is issued. may not be needed.
0    subs r1,r1,#1
    bne %B0

    ldr r0,=CLKCON        ;enter STOP mode.
    str r2,[r0]

    mov r1,#32
0    subs r1,r1,#1    ;1) wait until the STOP mode is in effect.
    bne %B0        ;2) Or wait here until the CPU&Peripherals will be turned-off
            ;   Entering SLEEP mode, only the reset by wake-up is available.

    ldr r0,=REFRESH ;exit from SDRAM self refresh mode.
    str r3,[r0]

    MOV_PC_LR

ENTER_SLEEP
    ;NOTE.
    ;1) rGSTATUS3 should have the return address after wake-up from SLEEP mode.

    ldr r0,=REFRESH
    ldr r1,[r0]        ;r1=rREFRESH
    orr r1, r1, #BIT_SELFREFRESH
    str r1, [r0]        ;Enable SDRAM self-refresh

    mov r1,#16            ;Wait until self-refresh is issued,which may not be needed.
0    subs r1,r1,#1
    bne %B0

    ldr    r1,=MISCCR
    ldr    r0,[r1]
    orr    r0,r0,#(7  <  <17)  ;Set SCLK0=0, SCLK1=0, SCKE=0.
    str    r0,[r1]

    ldr r0,=CLKCON        ; Enter sleep mode
    str r2,[r0]

    b .            ;CPU will die here.


WAKEUP_SLEEP
    ;Release SCLKn after wake-up from the SLEEP mode.
    ldr    r1,=MISCCR
    ldr    r0,[r1]
    bic    r0,r0,#(7  <  <17)  ;SCLK0:0->  SCLK, SCLK1:0->  SCLK, SCKE:0->  =SCKE.
    str    r0,[r1]

    ;Set memory control registers
     ldr    r0,=SMRDATA
    ldr    r1,=BWSCON    ;BWSCON Address
    add    r2, r0, #52    ;End address of SMRDATA
0
    ldr    r3, [r0], #4
    str    r3, [r1], #4
    cmp    r2, r0
    bne    %B0

    mov r1,#256
0    subs r1,r1,#1    ;1) wait until the SelfRefresh is released.
    bne %B0

    ldr r1,=GSTATUS3     ;GSTATUS3 has the start address just after SLEEP wake-up
    ldr r0,[r1]

    mov pc,r0

    LTORG
HandlerFIQ      HANDLER HandleFIQ
HandlerIRQ      HANDLER HandleIRQ
HandlerUndef    HANDLER HandleUndef
HandlerSWI      HANDLER HandleSWI
HandlerDabort   HANDLER HandleDabort
HandlerPabort   HANDLER HandlePabort

IsrIRQ
    sub    sp,sp,#4       ;reserved for PC
    stmfd    sp!,{r8-r9}

    ldr    r9,=INTOFFSET     ; 读取INTOFFSET的地址
    ldr    r9,[r9]            ; 读取INTOFFSET的数据
    ldr    r8,=HandleEINT0 ; 读取HandleEINT0的地址
    add    r8,r8,r9,lsl #2 ; r8=r8+(r9  <  <2)
    ldr    r8,[r8]
    str    r8,[sp,#8]
    ldmfd    sp!,{r8-r9,pc}

;=======
; ENTRY
;=======
ResetHandler
    ldr    r0,=WTCON       ;watch dog disable
    ldr    r1,=0x0
    str    r1,[r0]

    ldr    r0,=INTMSK
    ldr    r1,=0xffffffff  ;all interrupt disable
    str    r1,[r0]
 ......

>>返回讨论的主题



  发表回复
用户名   *您没有注册?
密码   *
验证码   * .
标题   *
心情
随便说说    我回答你    最新发现    得意的笑   
气死我了    真是没劲    坚决同意    表示反对   
大家过来    好奇怪哟    懒得理它    大家小心   
文件上传
内容


字体:      字体大小:    颜色:
粗体 斜体 下划线 居中 超级连接 Email连接 图片 Flash图片 Shockwave文件 realplay视频文件 Media Player视频文件 QuickTime视频文件 引用 飞行字 移动字 发光字 阴影字 查看更多的心情图标 背景音乐
点击加入表情
                         
选项
有回复时用短消息通知您?

   




老古网执行:62毫秒 最大:8219毫秒 查询6次