About SWI functions in the LPC3250

Source: Internet
Author: User

 

Take a look at the function call details:

Example:

1 In main. c

MicIrqFuncSet (timerrentint, 2, (unsigned int) IRQ_Timer1 );

The micIrqFuncSet function calls the function in viccontrol. h.

2 In viccontrol. h

_ Inline unsigned int micIrqFuncSet (unsigned int uiChannel,
Unsigned int uiType,
Unsigned int uiFuncAddr)
{
Return swiHandle (0x100, uiChannel, uiType, uiFuncAddr );
}

The inline function is used here, that is, the swiHandle function is actually called.

_ Swi (0x01) unsigned int swiHandle (int iHandle, unsigned int );

3 In vicControl. s

Swihandle is actually swi software interrupt, there are 4 parameters, passed to the R0-R3 respectively.

Supplement: The SWI execution process is to first enter the abnormal interrupt vector table, then jump to the vector address, and then perform a small assembly operation to read the function number into a register, switch to determine the number of the function, and then jump to the corresponding terminal service program. If the function has parameters, the parameters are transmitted according to the ATPCS rule. If there is only one parameter, it is passed using R0. More than four parameters are passed, and more than four parameters are passed using stacks.

So here iHandle = 0x100, so according to the swi interrupt vector table

VicControl
SUB R0, R0, #0x100
CMP R0, #0x12
Ldrlo pc, [PC, R0, LSL #2]
Movs pc, LR

VicControlFuncAdd
DCD SetmicIrqFunc; 0
DCD ClrmicIrqFunc; 1
DCD enablemicirq; 2
DCD disablemicirq; 3
DCD setmicfiq; 4
DCD clrmicfiq; 5

DCD Setsic1IrqFunc; 6
DCD Clrsic1IrqFunc; 7
DCD Enablesic1Irq; 8
DCD Disablesic1Irq; 9
DCD Setsic1Fiq; 10
DCD Clrsic1Fiq; 11

DCD Setsic2IrqFunc; 12
DCD Clrsic2IrqFunc; 13
DCD Enablesic2Irq; 14
DCD Disablesic2Irq; 15
DCD setsic2fiq; 16
DCD clrsic2fiq; 17
It is known that the code segment jump to setmicirqfunc for execution.

4 setmicirqfunc code segment

Setmicirqfunc
CMP R1, #32; If (channel number> = 32) return false
Movcs r0, #0
Movcss PC, LR

CMP R2, #4; If (trigger type> = 4) return false
Movcs r0, #0
Movcss PC, LR

CMP R3, #0; if (processing function = 0) return FALSE
MOVEQ R0, #0
Moveqs pc, LR

MSR CPSR_c, # (NoFIQ | NoInt | SYS32Mode)
Stmfd sp !, {R2, R3}
MOV R3, #1
MOV R3, R3, LSL R1

LDR R0, = MIC_ITR; if (Enable) return FALSE
LDR R2, [R0]
ANDS R2, R2, R3
BNE setmicirqfunc_j

LDR r0, = vectstackspace; If (IRQ enabled) return false
LDR R2, [r0, R1, LSL #2]
CMP R2, #0

Here the interrupt control register is set based on the passed R0-R3 parameters. The entire interrupt configuration is completed.

 

 

The above is the call of the interrupt function in the lpc3250.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.