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  [ 4 posts ] 
Author Message
 Post subject: Handling all interrupts in the AT91SAM7X
PostPosted: Wed Mar 02, 2011 4:15 pm 
Offline

Joined: Wed Mar 02, 2011 3:55 pm
Posts: 2
Hello all,

I'm writing an application that contains various interrupt sources: 3 from timers and 2 from the PIO controllers. I want to make sure that all interrupt are handled, none may be ignored.

A small section from my code needs to run un-interrupted, so for this i disable the interrupts for a small time. The code looks like this:

AT91C_BASE_AIC->AIC_IDCR = (0x1 << AT91C_ID_TC0) + (0x1 << AT91C_ID_TC1) + (0x1 << AT91C_ID_TC2) + (0x1 << AT91C_ID_PIOA) + (0x1 << AT91C_ID_PIOB);
//do important code here
AT91C_BASE_AIC->AIC_IECR = (0x1 << AT91C_ID_TC0) + (0x1 << AT91C_ID_TC1) + (0x1 << AT91C_ID_TC2) + (0x1 << AT91C_ID_PIOA) + (0x1 << AT91C_ID_PIOB);

Any interrupts generated during this small time need to be handled after the interrupts are back enabled. I assume that this happens during normal operation.

The problem comes when an interrupt is labeled as spurious because it occurs simultaniously with the masking. Then the AIC jumps to the spurious interrupt handler. Here i do a AT91C_BASE_AIC->AIC_EOICR = 0x000000; and get on with the program.

My question: Is the interrupt labeled as spurious still present after i enable them again? In other words, will it be handled with its normal interrupt routine or is it gone and do i need to catch it in the spurious interrupt routine?

Any help is greatly appreciated :)

Kind regards,
Youri


Top
 Profile  
 
 Post subject: Re: Handling all interrupts in the AT91SAM7X
PostPosted: Wed Mar 02, 2011 9:45 pm 
Offline

Joined: Sat Oct 30, 2010 6:04 pm
Posts: 574
What are you doing that requires the interrupts to be disabled?

Wouldn't using the ARM's CPSR to disable interrupts be a more effective way of doing so?

MRS r0, cpsr
ORR r0, r0, #I_Bit:OR:F_Bit ;disable IRQ and FIQ interrupts
MSR cpsr_c, r0

I'm pretty sure the AIC isn't going to re-characterize an interrupt once it's been tagged as spurious, you'll have to catch that, and shop it around between the potential sources to see who's it is.


Top
 Profile  
 
 Post subject: Re: Handling all interrupts in the AT91SAM7X
PostPosted: Thu Mar 03, 2011 8:04 am 
Offline

Joined: Wed Mar 02, 2011 3:55 pm
Posts: 2
Thanks for your response.

The base of my program is an event censored. Events are mostly generated by interrupts and the censored is checked and handled in the main routine. It has a read and a write pointer and when an event is handled in the main, there can't be any new events from interrupt because it screws up my pointers. That's why i need to disable the interrupts. But i don't want to loose any.

I'm no expert in assembly code so, what is then the code to re-enable them?

I'll do some testing with catching my critical interrupts in the spurious routine.


Top
 Profile  
 
 Post subject: Re: Handling all interrupts in the AT91SAM7X
PostPosted: Thu Mar 03, 2011 6:28 pm 
Offline

Joined: Sat Oct 30, 2010 6:04 pm
Posts: 574
semaphore?

If you are queuing events you should be able to build a interrupt safe ring-buffer/FIFO structure. The interrupt advances the head, and the foreground task consumes from the tail, so neither touches the same pointer.

Personally, I'd store the original condition away and restore it with a

MSR cpsr_c, r0

or if you know both are enabled

MRS r0, cpsr
BIC r0, r0, #I_Bit:OR:F_Bit ;enable IRQ and FIQ interrupts
MSR cpsr_c, r0


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

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: Bing [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: