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  [ 6 posts ] 
Author Message
 Post subject: Interrupt, __arm and __irq
PostPosted: Fri Feb 04, 2005 7:02 pm 
Offline

Joined: Fri Feb 04, 2005 3:37 pm
Posts: 2
I'm experimenting with the AR91SAM7S-EK and the IAR compiler that comes with it. The compiler manual specifies that all interrupt handlers must be compiled in ARM (not THUMB) mode, and that interrupt functions must be specified with the __irq keyword or #pragma type_attribute=__irq statement.
In the interrupt example that comes with the EK, it appears that neither of these two rules are followed?
I must be missing something.
Can someone clarify this for me?
Thanks in advance for the help.

_________________
Best Regards,
Dennis


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 07, 2005 1:30 pm 
Offline
User avatar

Joined: Thu Feb 12, 2004 7:48 pm
Posts: 164
Location: Atmel Corp.
Hi db_from_mn,

There are two rules:
1) The ARM processor executes all interrupt (in IRD or FIQ) in ARM Mode and not in Thumb Mode. This is the reason you have to compile interrupt sub-routine in ARM.
2) Use the __irq cannot use embedded AIC. I advise you to take a look at the on-line training, under AT91 Interrupt Handling.

Keep in touch


Top
 Profile  
 
 Post subject: __arm and __irq
PostPosted: Mon Feb 07, 2005 5:41 pm 
Offline

Joined: Fri Feb 04, 2005 3:37 pm
Posts: 2
Hello Scadene,
Thanks for the reply, but I'm still confused.
If the AIC is used, then the __arm and __irq rules do not apply?
The AIC ultimately drives the __irq of the core.

_________________
Best Regards,
Dennis


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 07, 2005 9:28 pm 
Offline

Joined: Mon Nov 08, 2004 4:39 pm
Posts: 120
Location: Raleigh, NC
My initial guess was that the custom C_startup module that is included in this project handles the installation of interrupt service routines.

Then I realized this is the case by looking at the c_startup code provided in the example. In there you will see labels for IRQ_Handler_Entry: and FIQ_Handler_Entry:

You install your isrs by making calls to the function in the API library that handles that, such as:

AT91F_AIC_ConfigureIt ( pAic, AT91C_ID_PIOA, PIO_INTERRUPT_LEVEL,AT91C_AIC_SRCTYPE_INT_LEVEL_SENSITIVE, pio_c_irq_handler);

Personally, I like this approach, but it is probably not best if you plan to work with other vendors ARM parts, too. I guess Atmel wanted to show off the API (which is one of the strongest points about the SAM7, no other semiconductor vendor has such good support code).

Normally, I would have used the keywords. Note, that when the keywords are used, the compiler is smart enough to emit ARM code for the isr instead of Thumb code.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 08, 2005 1:18 am 
Offline
User avatar

Joined: Fri Feb 13, 2004 7:53 pm
Posts: 329
the __irq is a facility provided by the Tool.

It instals a simple, non nested ISR. This avoid you to have an ASM macro or ASM ISR which allows nested IRQ etc. I would say that it is the "Hello World" of the interrupt handler in some cases :D

Cheers.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 11, 2005 7:30 pm 
Offline
User avatar

Joined: Fri Feb 13, 2004 7:53 pm
Posts: 329
More details...

the __arm keyword tells the compiler to compile the function in ARM code since the ARM core switches to ARM mode when in IRQ mode.
the __irq keyword is a facility provide by the tool, which allows you to write ISR in C only. But you have to use __irq with care.
You can write simple C interrupt handlers by using the __irq function declaration keyword. The __irq keyword can be used for both simple one-level interrupt handlers, and interrupt handlers that call subroutines. However, you cannot use the __irq keyword for reentrant interrupt handlers, because it does not cause the SPSR to be saved or restored. In this context, reentrant means that the handler re-enables interrupts, and may itself be interrupted.

In our examples we do not use these two keywords since we want reentrant IRQs which means that you have to write a part of the ISR in ASM to enable IRQs again, save and restore the SPSR and so on.

Hope it clarifies.


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

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 21 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: