Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: a problem about interrupt in the AT91SAM7S64
PostPosted: Thu Jan 07, 2010 8:53 am 
Offline

Joined: Sun Dec 27, 2009 1:40 pm
Posts: 10
I am a newer. I study the AT91SAM7S64 for a month. Now I encounter some problem. The code as below:
Code:

// Macros for Interrupt Nesting
#define IENABLE                             /* Nested Interrupts Entry */   \
  __asm { MRS     LR, SPSR      }           /* Copy SPSR_irq to LR     */   \
  __asm { STMFD   SP!, {LR}     }           /* Save SPSR_irq           */   \
  __asm { MSR     CPSR_c, #0x1F }           /* Enable IRQ (Sys Mode)   */   \
  __asm { STMFD   SP!, {LR}     }           /* Save LR                 */   \

#define IDISABLE                            /* Nested Interrupts Exit  */   \
  __asm { LDMFD   SP!, {LR}     }           /* Restore LR              */   \
  __asm { MSR     CPSR_c, #0x92 }           /* Disable IRQ (IRQ Mode)  */   \
  __asm { LDMFD   SP!, {LR}     }           /* Restore SPSR_irq to LR  */   \
  __asm { MSR     SPSR_cxsf, LR }           /* Copy LR to SPSR_irq     */   \


extern AT91S_PIO * pPIO;                    /* Global Pointer to PIO */


void irq0_int (void) __irq __atr {          /* IRQ0 (Push button SW2)    */

  IENABLE;                                  /* Enable Interrupt nesting  */
  if ((pPIO->PIO_PDSR & SW2) == 0) {        /* Check if SW2 is pressed   */
    pPIO->PIO_CODR = LED2;                  /* Turn On LED2              */
    while ((pPIO->PIO_PDSR & SW2) == 0);    /* Wait until SW2 is pressed */
    pPIO->PIO_SODR = LED2;                  /* Turn Off LED2             */
  }
  IDISABLE;                                 /* Disable Interrupt nesting */
  *AT91C_AIC_EOICR = 0;                     /* End of Interrupt          */
}




Can anybody explain the below code in detail:
Code:

__asm { MSR     CPSR_c, #0x1F }           /* Enable IRQ (Sys Mode)   __asm { MSR     CPSR_c, #0x92 }           /* Disable IRQ (IRQ Mode)  */   


We can set the priority of interrupt by the below code:
Code:
pAIC->AIC_SMR[AT91C_ID_IRQ0] = AT91C_AIC_SRCTYPE_INT_EDGE_TRIGGERED | 1;


Why we have to use the IENABLE, IDISABLE in the program?? Is it unnecessary or somrthing else??? :?: :?:


cheng_bei


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: