EmbDev.net

Forum: ARM programming with GCC/GNU tools never ending interrupt?


von Greg (Guest)


Rate this post
useful
not useful
Hello,

I have a problem with timer`s interrupt. I use Timer 1 to generate IRQ
interrupt. When ISR is done the next interrupt is generate and so on but
without any execution of others instructions (those outside of ISR). So
it seems to be never ending interrupt what is strange for me because I
clear the interrupt flag in ISR (see below).


void initVIC(void){
/*reset interrupts by writing a logic one to the corresponding IR bit*/
  T1IR = IR_MR0_INT;
/* Initialize VIC */
  VICIntSelect = ~(INT_TIMER1);  // Those interrupts selected as IRQ
  VICIntEnable = (INT_TIMER1);  // TIMER1 interrupt enabled

  VICVectCntl0 = SLOT_TIMER1;  // assign interrupt to slot 0

  VICVectAddr0 = (unsigned long)ISRtimer1;  // Address of the ISR
  enableIRQ();
}


void initTIMER(void){
/* Initialize Timer1 */
  T1PR = 0x0;  //Prescaler Register - divide PCLK by (T1PR+1).
  T1MR0 = 2750;   //Match Register.
  T1MCR = 0x3;   //Match Control Register (interrupt & reset TC when
TC=T1MR0)
  T1TCR = 0x2;  //reset Timer Counter (I enable counter in main function
writing 0x1 to

this register)
      T1IR = 0x1;  //reset Timer0 interrupt
}


void ISRtimer1(void){
  uint16_t sample;
  ISR_ENTRY();
  T1IR = IR_MR0_INT; //clear interrupt flag

  IOPIN1 = ~IOPIN1;

  if(PCMcount > 0){
    sample = (PCMbuf[PCMtail] + PCM_RANGE / 2) / (PCM_RANGE /
DAC_RANGE);
    DACR = ((sample << 6) | DAC_BIAS);

    PCMcount--;
    PCMtail++;
    if(PCMtail == PCMsize)
      PCMtail = 0;
  }

    VICVectAddr = 0x00000000;  // clear this interrupt from the VIC
  ISR_EXIT();                     // recover registers and return
}


If it is important I set up the stack sizes in Crt0.S as follows:
// Stack Sizes

  .set  UND_STACK_SIZE, 0x00000004
        .set  ABT_STACK_SIZE, 0x00000004
        .set  FIQ_STACK_SIZE, 0x00000004
        .set  IRQ_STACK_SIZE, 0X00000100
        .set  SVC_STACK_SIZE, 0x00000004
        .set  USR_STACK_SIZE, 0x000006e0

and in linker script:
STACK_SIZE = 0x800;

I can`t understand it and I don`t know how to resolve this problem.
I use GCC 4.1.1 (WinARM) and LPC2138 uC.

Could someone help me to resolve this problem?
Thanks a lot.

Greg

von Martin Thomas (Guest)


Rate this post
useful
not useful
> void ISRtimer1(void){
>   uint16_t sample;
>   ISR_ENTRY();
>   T1IR = IR_MR0_INT; //clear interrupt flag
...

Since you are using the "Macro-approach" with ISR_ENTRY and ISR_EXIT:
Did you try to add the "naked" function-attribute to the ISRtimer1()
function?
How are the exception-vectors configured?

Martin Thomas

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.