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

lpc2378 crash

hello,
I'm using Keil Realview compiler with the MCB2300 board (lpc2378). I've a simple program that toggles a pin every 1 msec using a timer 0 interrupt.
In the main loop a array is being filled and another pin is toggled.
When I run the program it crashes.
When I disable the timer interrupt the main loop runs ok.
When I enable the timer interrupt and disable the line that fills the array it also works ok.

When I run the debugger untill the program crashes it ends up in data abort mode.
Does anyone have an idea on how to solve this problem?

Below is the related code.

Kind regards,
Sander Wiggers

/*************************** FUNCTION ************************************/
bool init_timer_interrupt(void)
/*************************** INFO ****************************************
**
** DESCRIPTION : Init timer interrupt.
**
**               The timer interrupt will be activated with an 1ms
**               interval.
**************************************************************************/
{
  uint32 prescaler;
  uint32 timer_val;

  prescaler = (F_PCLK / 1000000) - 1;
  timer_val = 1000;

  T0TCR  = 0x02;
  T0CTCR = 0x00;
  T0MR0  = timer_val;
  T0PR   = prescaler;

  if(!install_irq(TIMER0_INT, (void *)timer0_isr, PRIORITY_2))
  {
    return(FALSE);
  }
  else
  {
    T0TCR = 0x01;
    T0MCR = 0x0003;
    return(TRUE);
  }
}

/*************************** FUNCTION ************************************/
void timer0_isr(void)
/*************************** INFO ****************************************
**
** DESCRIPTION : Timer Interrupt (1ms).
**************************************************************************/
{
  T0IR = 0x01;

  FIO2SET = 0x00000040;
  FIO2CLR = 0x00000040;
}

;--------------------------------------------------------------------------------------
;- START IRQ Handler
;--------------------------------------------------------------------------------------
                EXPORT  IRQ_Handler
IRQ_Handler
; First store LR and other registers
        SUB     LR, LR, #4
        STMFD   SP! ,{R12, LR}  ; push LR_irq and R12 onto the stack
; Check I_bit to avoid spurious interrupts
        MRS     LR, SPSR        ; put spsr into LR
        ANDS    LR, LR, #I_Bit  ; check if I Bit is set
        LDMNEFD SP!, {PC}^      ; if so, return immediatley
; Save SPRS
        MRS     R12, SPSR       ; copy spsr into R12
        STMFD   SP!, {R12}      ; push spsr (R12) onto the stack
; Read VICVectAddr to get the active IRQ handler address
        LDR     LR, =0xFFFFF000         ; load VIC base address
        LDR     R12, [LR, #0xF00]       ; add offset to base address (VICVectAddr)
; Enable nested interrupts
        MSR     cpsr_c, #Mode_SYS       ; enable IRQ by switching to system mode
        STMFD   SP!, {R0-R3, LR}        ; push LR_sys and R0-R3 onto the stack
; Jump to C IRQ handler
        MOV     LR, PC                  ; store pc into lr
        BX      R12                     ; branch to C handler
; Pop registers from stack and return to IRQ mode
        LDMFD   SP!, {R0-R3, LR}        ; pop LR_sys and R0-R3 from stack
        MSR     cpsr_c, #I_Bit | Mode_IRQ ; return to IRQ mode and set I bit
        LDMFD   SP!, {R12}              ; pop R12 from stack
        MSR     spsr_cxsf, R12          ; restore SPSR (R12)
        LDR     R1, =0xFFFFFF00         ; load VICVectAddr into R1
        STR     R0, [R1]                ; acknowledge irq by writing something to VICVectAddr
        LDMFD   SP!, {R12, PC}^         ; pop R12 and LR_irq from stack
;--------------------------------------------------------------------------------------
;- END IRQ Handler
;--------------------------------------------------------------------------------------

#define ARRAY_SIZE  75
uint32 displ_data2[ARRAY_SIZE];
/*************************** FUNCTION ************************************/
sint32 main(void)
/*************************** INFO ****************************************
**
** DESCRIPTION : Main Program.
**************************************************************************/
{
  uint16 x;

  init_mbc_ports();
  init_vic();
  init_timer_interrupt();

  FIO2DIR |= 0x000000F0;

  while(TRUE)
  {
    FIO2SET = 0x00000080;

    for(x = 0; x < ARRAY_SIZE; x++)
      displ_data2[x] = 0xff;

    FIO2CLR = 0x00000080;
  }
}

0