LPC interrupt problems

I’ve tried to initialize a UART RX interrupt (when RX buffer has a character, trigger the interrupt)

It didn’t work.

I’ve tried IAR example “/simple/uart” and I injected my code there. In their project with my code, interrupt worked. In my project with the same C code, didn’t.

The only difference was the presence of cstartup.s

Can I avoid this file?

What can I do in my source code to avoid including this file? (i hate using someone else code)

Part of cstartup file:

__iar_program_start:
?cstartup:

I_Bit    DEFINE 0x80            ; when I bit is set, IRQ is disabled
F_Bit    DEFINE 0x40            ; when F bit is set, FIQ is disabled

#define VIC_INT_ENABLE  0xFFFFF014
; Disable all interrupts
                ldr   r0,=VIC_INT_ENABLE
                mov   r1,#0xFFFFFFFF
                str   r1,[r0]

; Execution starts here.
; After a reset, the mode is ARM, Supervisor, interrupts disabled.
; Initialize the stack pointers.
; The pattern below can be used for any of the exception stacks:
; FIQ, IRQ, SVC, ABT, UND, SYS.
; The USR mode uses the same stack as SYS.
; The stack segments must be defined in the linker command file,
; and be declared above.

                mrs         r0,cpsr                             ; Original PSR value
                bic         r0,r0,#MODE_MSK                     ; Clear the mode bits
                orr         r0,r0,#SVC_MODE                     ; Set Supervisor mode bits
                msr         cpsr_c,r0                           ; Change the mode
                ldr         sp,=SFE(SVC_STACK)                  ; End of SVC_STACK
        
                bic         r0,r0,#MODE_MSK                     ; Clear the mode bits
                orr         r0,r0,#UND_MODE                     ; Set Undefined mode bits
                msr         cpsr_c,r0                           ; Change the mode
                ldr         sp,=SFE(UND_STACK)                  ; End of UND_MODE
        
                bic         r0,r0,#MODE_MSK                     ; Clear the mode bits
                orr         r0,r0,#ABT_MODE                     ; Set Data abort mode bits
                msr         cpsr_c,r0                           ; Change the mode
                ldr         sp,=SFE(ABT_STACK)                  ; End of ABT_STACK
        
                bic         r0,r0,#MODE_MSK                     ; Clear the mode bits
                orr         r0,r0,#FIQ_MODE                     ; Set FIR mode bits
                msr         cpsr_c,r0                           ; Change the mode
                ldr         sp,=SFE(FIQ_STACK)                  ; End of FIQ_STACK
        
                bic         r0,r0,#MODE_MSK                     ; Clear the mode bits
                orr         r0,r0,#IRQ_MODE                     ; Set IRQ mode bits
                msr         cpsr_c,r0                           ; Change the mode
                ldr         sp,=SFE(IRQ_STACK)                  ; End of IRQ_STACK
        
                bic         r0,r0,#MODE_MSK | I_Bit | F_Bit     ; Clear the mode bits
                orr         r0,r0,#SYS_MODE                     ; Set System mode bits
                msr         cpsr_c,r0                           ; Change the mode
                ldr         sp,=SFE(CSTACK)                     ; End of CSTACK

part of my C code

extern void init_irq()

{

DWORD volatile *pVectorAddress;

DWORD volatile *pVectorPriority;

/* all irq channels assigned to IRQ */

VICINTSELECT = 0;

/* disable all interrupts*/

VICINTENCLEAR = 0xFFFFFFFF;

/* clear all software interrupts */

VICSOFTINTCLEAR = 0xFFFFFFFF;

/* VIC registers can be accessed in User or privileged mode */

VICPROTECTION_bit.VIC_ACCESS = 0;

/* Clear interrupt */

VICADDRESS = 0;

/* Clear all adresses for vectors */

pVectorAddress = &VICVECTADDR0;

pVectorPriority = &VICVECTPRIORITY0;

for(DWORD i = 0; i < VIC_SIZE; i++)

{

*pVectorAddress++ = 0x00;

*pVectorPriority++ = 0x0F;

}

}

extern BOOL add_irq_handler( DWORD dwIntNumber, void *IntFunction, DWORD dwPriority )

{

DWORD *pVectorAddress;

DWORD *pVectorPriority;

VICINTENCLEAR = 1 << dwIntNumber; // disable Interrupt

if ( dwIntNumber >= VIC_SIZE ) // maximum nr. of interrupt sources is 32

return ( FALSE );

pVectorAddress = (DWORD )( 0xFFFFF100 + dwIntNumber4);

pVectorPriority = (DWORD )(0xFFFFF200 + dwIntNumber4);

*pVectorAddress = (DWORD)IntFunction; // set interrupt vector

*pVectorPriority = dwPriority;

//VICINTSELECT = 1 << dwIntNumber;

VICINTENABLE = 1 << dwIntNumber; // enable interrupt

return TRUE;

}