This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Invoking SWI from C code

Iam using Keil MDK V4.20.03.0. I have referred "SWI Functions" under Keil Help for trying to invoke software interrupt from my C code as shown below,

#include <LPC23xx.H>

unsigned int VAL = 0x000000a5;

int __SWI(0) SWICall(unsigned int);

int __SWI_0(unsigned int VAL)
{
  return VAL;
}

void init(void){
        PINSEL4 = 0x00000000;
        FIO2DIR = 0x000000ff;
        FIO2PIN = SWICall();
}

int main(void){
        init();

        while(1){
          FIO2PIN = 0x000000aa;
          delay();
          FIO2PIN = 0x00000055;
          delay();
        }
}

I have also included the SWI.s file from C:\Keil\startup\ , within which i have uncommented the code statements related to SWI 0

SWI_Cnt         EQU    (SWI_End-SWI_Table)/4
SWI_Count       DCD     SWI_Cnt

; Import user SWI functions here.
                IMPORT  __SWI_0
               ;IMPORT  __SWI_1
               ;IMPORT  __SWI_2


SWI_Table
; Insert user SWI functions here
                DCD     __SWI_0                ; SWI 0 Function Entry
               ; DCD    __SWI_1                ; SWI 1 Function Entry
               ; DCD    __SWI_2                ; SWI 2 Function Entry

SWI_End

But, i see the following errors/warnings which i am unable to resolve,

Build target 'Target 1'
assembling LPC2300.s...
compiling switest.c...
switest.c(5): error: #79: expected a type specifier
switest.c(5): error: #141-D: unnamed prototyped parameters not allowed when body is present
switest.c(5): error: #130: expected a "{"
switest.c(8): warning: #12-D: parsing restarts here after previous syntax error
switest.c(16): warning: #223-D: function "SWICall" declared implicitly
switest.c(24): warning: #223-D: function "delay" declared implicitly
assembling SWI.s...
Target not created

Request your valuable suggestions to help me resolve this problem.

0