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 Interrupt problem - can't enable interrupts on ADuC7024

Hello, everyone!

I'm having the following problem. I'm using a ADXL345 development board from Analog Devices (with the ADuC7024 MCU and a ADXL345 accelerometer). I would like to implement the algorithm from the following paper:

www.analog.com/.../fall_detector.html
(Hear is a copy of the paper with the source code - www.analog.com/.../AN-1023.pdf)

There is also source code provided with the paper. The problem is that after compilation (and substitution of the __fiq token with the __irg because __fiq is no longer allowed in uVision4) I tested the coded and nothing happened. It looked as if no interrupts were ever generated and/or handled. This is why I decided to write a simple program that uses interrupts generated from Timer0 to toggle a LED on the board. I hereby post the code and the startup code.

Any help or ideas will be greatly appreciated!

Blinky_Interrupt:

#include <ADuC7024.H>                      /* ADuC7024 definitions */

void wait (void)  {                        /* wait function */
  unsigned long i;                         /* Delay var */

  for (i = 0; i < 100000; )  {             /* Delay for 100000 Counts */
    i++;
  }
}

void Interrupt_Init(void)
{
        IRQEN = RTOS_TIMER_BIT;         // Timer 0 => Interrupt
}

void Timer_Init(void)
{
        T0LD  |= 0xFFFF;     // Loads value 0xFFFF in Timer 0
        T0CON |= 0xC0;       // Enabled,Periodic,CLK/1
}

void POW_Init(void)     // POWCON controls the core clock frequency and the power-down mode
{
          POWKEY1 = 0x01;
          //POWCON = 0x03;                       // Selects core frequency 5.22 MHz
          POWCON = 0x07;                         // Selects core frequency 326 kHz
          POWKEY2 = 0xF4;
}

void My_IRQ_Handler(void)__irq // Timer 0 => Interrupt
{
        if((IRQSIG & RTOS_TIMER_BIT)==RTOS_TIMER_BIT){
                T0CLRI = 0xF0;                     /* Clear interrupt */
                GP4DAT ^= 0x00400000;              /* Toggle P4.5 */
        }
}


int main(void) {
        GP4DAT &= 0x00000000;
        GP4DAT |= 0x40000000;                           /* P4.5 defined as outputs */
        GP4DAT ^= 0x00400000;                           /* Toggle LED1 */

        POW_Init();
        Timer_Init();
        Interrupt_Init();
        while(1) {
                ;//if (T0VAL <= 0x00FF) GP4DAT ^= 0x00400000;      /* Toggles LED1 */

        }
}

In the startup code I have:
Startup code:

; Exception Vectors
;  Mapped to Address 0.
;  Absolute addressing mode must be used.
;  Dummy Handlers are implemented as infinite loops which can be modified.

Vectors         LDR     PC, Reset_Addr
                LDR     PC, Undef_Addr
                LDR     PC, SWI_Addr
                LDR     PC, PAbt_Addr
                LDR     PC, DAbt_Addr
                NOP                            ; Reserved Vector
                LDR     PC, IRQ_Addr
                LDR     PC, FIQ_Addr

                EXTERN Undef_Handler
                EXTERN SWI_Handler
                EXTERN PAbt_Handler
                EXTERN DAbt_Handler
                EXTERN My_IRQ_Handler
                EXTERN FIQ_Handler

Reset_Addr      DCD     Reset_Handler
Undef_Addr      DCD     Undef_Handler
SWI_Addr        DCD     SWI_Handler
PAbt_Addr       DCD     PAbt_Handler
DAbt_Addr       DCD     DAbt_Handler
                DCD     0                      ; Reserved Address
IRQ_Addr        DCD     My_IRQ_Handler
FIQ_Addr        DCD     FIQ_Handler

Undef_Handler   B       Undef_Handler
SWI_Handler     B       SWI_Handler
PAbt_Handler    B       PAbt_Handler
DAbt_Handler    B       DAbt_Handler
;IRQ_Handler     B       IRQ_Handler
FIQ_Handler     B       FIQ_Handler
; Reset Handler

                EXPORT  Reset_Handler
Reset_Handler


When I debug it in Keil, I see that the timer is counting down and starts all over again every 0.2 sec (as expected) and the values of the following registers are:

IRQEN -> 0x00000004
IRQSTA -> 0x00000004
IRQSIG -> 0x00649005

And yet, the interrupt isn't handled and the LED isn't toggled.

Thank you again and sorry if this seems a stupid question!

0