Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

SWI Interrupt

2006-01-22 by Balajee Premraj

Hi All,

I have this reference software code downloaded from
Keil website for interrupt driven Serial IO.

The software code uses SWI interrupt 8 and 9 for the
routines com_putchar() and com_getchar()

I added the swi_vec.s file into the project directory
and built the code.

However it does not seem to be working and on
debugging the code, i found that, printf , library
call uses SWI 8, 

it goes to the SWI_vec.s files, SWI_handler, and from
there the code gets looped inifinetly in b $ loop.


The keil linker should create a SWI table entry
automatically and fill in the SWI Table, Disassembling
the linker generated .cod file, i dont see this table
entry to be updated with the SWI 8 and SWI 9
functions.

How do i get the keil linker tool to update these
entries automatically.



These are the definitions

int com_putchar (int c) __swi(8)
int com_getchar (void) __swi(9)


swi_vec.s

/***********************************************************************/
/*  This file is part of the CA ARM C Compiler package
                */
/*  Copyright KEIL ELEKTRONIK GmbH 2002 - 2004        
                */
/***********************************************************************/
/*                                                    
                */
/*  SWI_VEC.S:  Pre-defined vectored interrupt handler
SWI interrupt   */
/*                                                    
                */
/***********************************************************************/

AREA ?C?SWI, CODE, READONLY, ALIGN=2

PUBLIC SWI_Handler?A, ?SWI?Table, ?SWI?Empty

SWI_Handler?A    PROC CODE32
        STMFD   SP!,{LR}           ; Store LR register
        MRS     R8,SPSR
        TST     R8,#0x20           ; SWI call from 
        LDRNEH  R8,[LR,#-2]        ; Thumb: Load
halfword instruction
        ANDNE   R8,R8,#0xFF        ;        extract
SWI number
        LDREQ   R8,[LR,#-4]        ; ARM:   Load word 
   instruction
        BICEQ   R8,R8,#0xFF000000  ;        extract
SWI number
                                   ; R4 now contains
SWI number
; SWI Handler
;       LDR     R12,[PC,#(?SWI?Table-$-8)] ; Maximum
number of interrupts
;       LDR     R12,[PC,#0x24]     ; Maximum number of
interrupts
        ADR     R12,?SWI?Table
        LDR     R12,[R12]          ; load last
SWI-Function-number

        CMP     R8,R12                                
            
        BGT     ?SWI?Empty         ; overflow
        ADR     R12,?SWI?Table+4
        LDR     R12,[R12,R8,LSL #2]; SWI function
address
        MOV     LR,PC              ; Return address
        BX      R12                ; Call SWI function

        LDMFD   SP!,{PC}^          ; Return

?SWI?Empty:
        B       $                  ; no existing SWI

; *** DO NOT MODIFY THIS PORTION OF THE FILE ***
?SWI?Table:                        ; Marker for LA
Linker                       
; 
; The LA Linker inserts at this label
;       DD      0                  ; <last SWI
function number>
;       DD      ?SWI?Empty         ; <entry for SWI
function 0>
;       DD      <SWI entry 1>
;       DD      <SWI entry 2>
;       DD           :
; For non-existing SWI functions DD ?SWI?Empty is
inserted

        ENDP

        END


After the compilation , i dont see this ?SWI?Table 
entry to be updated with the corresponding interrupt
functions.


Any help would be greatly appreciated.


Thanks,Balajee


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.