新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > S3C2440啟動代碼 中斷分析

S3C2440啟動代碼 中斷分析

作者: 時間:2016-11-22 來源:網(wǎng)絡(luò) 收藏

1.建立中斷向量表

b ResetHandler;hereis the first instrument 0x00這是第一條執(zhí)行的指令

本文引用地址:http://2s4d.com/article/201611/320025.htm

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

2. 設(shè)置缺省中斷處理函數(shù)

;將普通中斷判斷程序的入口地址給HandleIRQ

ldr r0,=HandleIRQ ;This routine is needed

ldr r1,=IsrIRQ ;ifthere isnt subs pc,lr,#4 at 0x18, 0x1c

str r1,[r0]

3.IRQ的中斷服務(wù)程序

IsrIRQ

sub sp,sp,#4;reserved for PC

stmfd sp!,{r8-r9}

ldr r9,=INTOFFSET ;地址為0x4a000014的空間存著中斷的偏移

ldr r9,[r9]

ldr r8,=HandleEINT0

add r8,r8,r9,lsl#2

ldr r8,[r8]

str r8,[sp,#8]

ldmfd sp!,{r8-r9,pc}

;外部中斷號判斷,通過中斷服務(wù)程序入口地址存儲器的地址偏移確定

;PC=[HandleEINT0+[INTOFFSET]]

4.中斷處理

HandlerFIQ HANDLER HandleFIQ

HandlerIRQ HANDLER HandleIRQ

HandlerUndef HANDLER HandleUndef

HandlerSWI HANDLER HandleSWI

HandlerDabort HANDLER HandleDabort

HandlerPabort HANDLER HandlePabort

5.將$HandleLabel地址空間中的數(shù)據(jù)給PC

MACRO

$HandlerLabel HANDLER $HandleLabel

$HandlerLabel

sub sp,sp,#4 ;decrementsp(to store jump address) sp=sp-4

stmfd sp!,{r0} ;PUSH the work register to stack(lr doest push because it return to originaladdress) r0進棧

ldr r0,=$HandleLabel;load the address ofHandleXXX to r0

ldr r0,[r0] ;load the contents(service routine start address) of HandleXXX

str r0,[sp,#4] ;store the contents(ISR) of HandleXXX tostack r0進棧,將ro中的數(shù)據(jù)寫入sp+4為地址的存儲器中

ldmfd sp!,{r0,pc} ;POP the work register and pc(jump to ISR) 恢復(fù)r0的值,同時也將$HandleLabel地址空間中的數(shù)據(jù)給PC

MEND

;將$HandleLabel地址空間中的數(shù)據(jù)給PC,中斷服務(wù)程序的入口

6 中斷向量表

ALIGN

AREARamData, DATA, READWRITE

^ _ISR_STARTADDRESS ; _ISR_STARTADDRESS=0x33FF_FF00

;表定位在 RAM 高端,基地址為 _ISR_STARTADDRESS

;^是MAP的同義詞,#是FIELD的同義詞

HandleReset # 4

HandleUndef # 4

HandleSWI # 4

HandlePabort # 4

HandleDabort # 4

HandleReserved # 4

HandleIRQ # 4

HandleFIQ # 4

HandleEINT0 #4

HandleEINT1 #4

HandleEINT2 #4

HandleEINT3 #4

HandleEINT4_7 # 4

HandleEINT8_23 # 4

HandleCAM #4 ; Added for 2440.

HandleBATFLT # 4

HandleTICK #4

HandleWDT #4

HandleTIMER0 #4

HandleTIMER1 #4

HandleTIMER2 #4

HandleTIMER3 #4

HandleTIMER4 # 4

HandleUART2 # 4

;@0x33FF_FF60

HandleLCD #4

HandleDMA0 #4

HandleDMA1 #4

HandleDMA2 #4

HandleDMA3 #4

HandleMMC #4

HandleSPI0 #4

HandleUART1 #4

HandleNFCON #4 ; Added for 2440.

HandleUSBD #4

HandleUSBH #4

HandleIIC #4

HandleUART0 #4

HandleSPI1 #4

HandleRTC #4

HandleADC # 4

7映射(定義一個指針的指針)

/ Exception vector

#define pISR_RESET (*(unsigned *)(_ISR_STARTADDRESS+0x0))

#define pISR_UNDEF (*(unsigned *)(_ISR_STARTADDRESS+0x4))

#define pISR_SWI (*(unsigned *)(_ISR_STARTADDRESS+0x8))

#define pISR_PABORT (*(unsigned *)(_ISR_STARTADDRESS+0xc))

#define pISR_DABORT (*(unsigned *)(_ISR_STARTADDRESS+0x10))

#define pISR_RESERVED (*(unsigned *)(_ISR_STARTADDRESS+0x14))

#define pISR_IRQ (*(unsigned *)(_ISR_STARTADDRESS+0x18))

#define pISR_FIQ (*(unsigned *)(_ISR_STARTADDRESS+0x1c))

// Interrupt vector

#define pISR_EINT0 (*(unsigned *)(_ISR_STARTADDRESS+0x20))

#define pISR_EINT1 (*(unsigned *)(_ISR_STARTADDRESS+0x24))

#define pISR_EINT2 (*(unsigned *)(_ISR_STARTADDRESS+0x28))

#define pISR_EINT3 (*(unsigned *)(_ISR_STARTADDRESS+0x2c))

#define pISR_EINT4_7 (*(unsigned *)(_ISR_STARTADDRESS+0x30))

#define pISR_EINT8_23 (*(unsigned *)(_ISR_STARTADDRESS+0x34))

#define pISR_CAM (*(unsigned *)(_ISR_STARTADDRESS+0x38)) // Added for 2440.

#define pISR_BAT_FLT (*(unsigned *)(_ISR_STARTADDRESS+0x3c))

#define pISR_TICK (*(unsigned *)(_ISR_STARTADDRESS+0x40))

#define pISR_WDT_AC97 (*(unsigned*)(_ISR_STARTADDRESS+0x44)) //Changedto pISR_WDT_AC97 for 2440A

#define pISR_TIMER0 (*(unsigned*)(_ISR_STARTADDRESS+0x48))

#define pISR_TIMER1 (*(unsigned*)(_ISR_STARTADDRESS+0x4c))

#define pISR_TIMER2 (*(unsigned *)(_ISR_STARTADDRESS+0x50))

#define pISR_TIMER3 (*(unsigned *)(_ISR_STARTADDRESS+0x54))

#define pISR_TIMER4 (*(unsigned *)(_ISR_STARTADDRESS+0x58))

#define pISR_UART2 (*(unsigned *)(_ISR_STARTADDRESS+0x5c))

#define pISR_LCD (*(unsigned *)(_ISR_STARTADDRESS+0x60))

#define pISR_DMA0 (*(unsigned *)(_ISR_STARTADDRESS+0x64))

#define pISR_DMA1 (*(unsigned *)(_ISR_STARTADDRESS+0x68))

#define pISR_DMA2 (*(unsigned *)(_ISR_STARTADDRESS+0x6c))

#define pISR_DMA3 (*(unsigned *)(_ISR_STARTADDRESS+0x70))

#define pISR_SDI (*(unsigned *)(_ISR_STARTADDRESS+0x74))

#define pISR_SPI0 (*(unsigned *)(_ISR_STARTADDRESS+0x78))

#define pISR_UART1 (*(unsigned *)(_ISR_STARTADDRESS+0x7c))

#define pISR_NFCON (*(unsigned *)(_ISR_STARTADDRESS+0x80)) // Added for 2440.

#define pISR_USBD (*(unsigned *)(_ISR_STARTADDRESS+0x84))

#define pISR_USBH (*(unsigned *)(_ISR_STARTADDRESS+0x88))

#define pISR_IIC (*(unsigned *)(_ISR_STARTADDRESS+0x8c))

#define pISR_UART0 (*(unsigned *)(_ISR_STARTADDRESS+0x90))

#define pISR_SPI1 (*(unsigned *)(_ISR_STARTADDRESS+0x94))

#define pISR_RTC (*(unsigned *)(_ISR_STARTADDRESS+0x98))

#define pISR_ADC (*(unsigned *)(_ISR_STARTADDRESS+0x9c))

8.一個中斷實例

Main()

{

KeyScan_Test;

}

void KeyScan_Test(void)

{

pISR_EINT0 =pISR_EINT2 = pISR_EINT8_23 = (U32)Key_ISR;

}

static void __irq Key_ISR(void)

{

}



關(guān)鍵詞: S3C2440啟動代碼中斷分

評論


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

關(guān)閉