<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          S3C2410中斷詳解

          作者: 時(shí)間:2016-11-11 來(lái)源:網(wǎng)絡(luò) 收藏
          最開(kāi)始的代碼,大家都很熟悉,最基本的中斷跳轉(zhuǎn)

          bResetHandler

          本文引用地址:http://www.ex-cimer.com/article/201611/316988.htm

          bHandlerUndef;handler for Undefined mode
          bHandlerSWI;handler for SWI interrupt
          bHandlerPabort;handler for PAbort
          bHandlerDabort;handler for DAbort
          b.;reserved
          bHandlerIRQ;handler for IRQ interrupt
          bHandlerFIQ;handler for FIQ interrupt

          跳轉(zhuǎn)的標(biāo)號(hào)是一系列的宏

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

          該宏在文件的最前面實(shí)現(xiàn),做了一些跳轉(zhuǎn)前的處理。如下:

          MACRO
          $HandlerLabel HANDLER $HandleLabel

          $HandlerLabel
          subsp,sp,#4 ;decrement sp(to store jump address)
          stmfdsp!,{r0} ;PUSH the work register to stack(lr doest 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

          以HandleIRQ跳轉(zhuǎn)為例說(shuō)明中斷的二級(jí)跳轉(zhuǎn)流程,以上的宏代碼說(shuō)明IRQ跳轉(zhuǎn)到了標(biāo)號(hào)HandleIRQ處,該標(biāo)號(hào)如下定義:(是一系列的中斷以及二級(jí)中斷入口地址)

          AREA RamData, DATA, READWRITE

          ^ _ISR_STARTADDRESS ;(該值自己定義,是存放中斷向量表的地址)
          HandleReset # 4
          HandleUndef # 4
          HandleSWI # 4
          HandlePabort # 4
          HandleDabort # 4
          HandleReserved # 4
          HandleIRQ # 4
          HandleFIQ # 4

          ;Dont use the label IntVectorTable,
          ;The value of IntVectorTable is different with the address you think it may be.
          ;IntVectorTable(二級(jí)IRQ中斷向量表)
          HandleEINT0 # 4
          HandleEINT1 # 4
          HandleEINT2 # 4
          HandleEINT3 # 4
          HandleEINT4_7# 4
          HandleEINT8_23# 4
          HandleRSV6# 4
          HandleBATFLT # 4
          HandleTICK # 4
          HandleWDT# 4
          HandleTIMER0 # 4
          HandleTIMER1 # 4
          HandleTIMER2 # 4
          HandleTIMER3 # 4
          HandleTIMER4 # 4
          HandleUART2 # 4
          HandleLCD # 4
          HandleDMA0# 4
          HandleDMA1# 4
          HandleDMA2# 4
          HandleDMA3# 4
          HandleMMC# 4
          HandleSPI0# 4
          HandleUART1# 4
          HandleRSV24# 4
          HandleUSBD# 4
          HandleUSBH# 4
          HandleIIC # 4
          HandleUART0 # 4
          HandleSPI1 # 4
          HandleRTC # 4
          HandleADC # 4

          而HandleIRQ由以下代碼賦值,可以看出跳轉(zhuǎn)到了IsrIRQ:

          drr0,=HandleIRQ ;This routine is needed
          ldrr1,=IsrIRQ ;if there isnt subs pc,lr,#4 at 0x18, 0x1c放置中斷跳轉(zhuǎn)
          strr1,[r0]

          IsrIRQ ;真正的IRQ中斷的入口
          subsp,sp,#4 ;reserved for PC留出一個(gè)位置保存中斷入口地址
          stmfdsp!,{r8-r9}

          ldrr9,=INTOFFSET
          ldrr9,[r9] ;讀入中斷偏移碼
          ldrr8,=HandleEINT0 ;二級(jí)跳轉(zhuǎn)表的首地址
          addr8,r8,r9,lsl #2 ;R8=R8+R9X4得到相應(yīng)的中斷入口地址
          ldrr8,[r8]
          strr8,[sp,#8] ;中斷入口地址送進(jìn)SP(第一個(gè)代碼留出的4字節(jié)空間)
          ldmfdsp!,{r8-r9,pc}

          到此為止,中斷已經(jīng)順利的進(jìn)入了中斷向量表,用C語(yǔ)言編寫(xiě)服務(wù)程序已變的非常簡(jiǎn)單。如EINT0中斷的ISR

          void Eint0(void)

          { }

          pISR_EINT0=(U32)Eint0; //用中斷入口指向函數(shù)指針即可。



          關(guān)鍵詞: S3C2410中斷詳

          評(píng)論


          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();