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

ADuC 70xx timer interupt problem

Hi
I'm starting with ADuC70xx I got a small problem with timer 0 interupt.
Program does not go to handling routine. I tried many egzamples without but didn't fond the wright one for ADuC

#define CLOCK  22544384   // CPU configured for 22.544384 MHz clock
#define T0_Freq  300       // Timer 0 Reload Frequency
#define T0_LD ((unsigned short )(CLOCK / 16 / T0_Freq))

void IRQ_Handler (void) __attribute__ ((interrupt("IRQ_Handler")));

void IRQ_Handler (void)
{  while (!IRQSIG & 0x00000004)  {                     /* Timer0 Interrupt          */

  GP4DAT ^= 0x00040000;
  T0CLRI = 1;                                     /* Clear Timer 0 interrupt   */
 }
 return;
}

void main (void)
{
GP4DAT = 0x04000000;
/*-------------------------------------
Initialize Timer 0 Interrupt
-------------------------------------*/
  IRQEN = 0x00000004;         /* Configure Timer 0                               */
  T0LD  = T0_LD;              /* Timer reload value                              */
  T0CON = 0xC0;               /* Enable Timer 0, Mode: periodic, prescaler = 1   */

while (1){
  }
}

What I'm doing wrong ??

  • A few points that may help you.

    You don't state it explicitly but I am assuming you are using a GNU ARM compiler.

    void IRQ_Handler (void) __attribute__ ((interrupt("IRQ_Handler")));
    


    IRQ, FIQ, SWI, ABORT and UNDEF are the only valid parameters to the interrupt function attribute.

    I have seem problems with the code that arm-uclibc-gcc v3.3.1 generates for a function using an invalid function parameter like this. The return from interrupt instruction – sub pc, r14,#14 – was omitted completely and control just flowed into the next function. It may be a problem with the gcc version you are using as well. No warning is given by the compiler.

    The start-up code sets up the IRQ vector location. Does it point to your handler? The interrupt function attribute does not update the vector location to point to your function. (The C51 compiler does).

    You should also ensure that the handler in compiled in ARM mode and not in THUMB mode for obvious reasons.