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  [ 3 posts ] 
Author Message
 Post subject: Nested Interrupts on SAM7X with AT9Lib & Keil µVision
PostPosted: Fri Nov 11, 2011 12:19 pm 
Offline

Joined: Thu Nov 03, 2011 11:55 am
Posts: 2
Location: Ulm, Germany
Hi all,

I'm working on a selfmade board with many IOs. A SAM7X512 will be the brain in the middle. Getting commands via CAN and setting PWM, IO, Analog-Out, stepper control and so on.
For this functionality I need several nested interrupts.

Here some information: I use the µVision4 IDE (didn't get the Yagarto/Eclipse/J-Link stuff to flash/debug the sam7x) with the Atmel AT91Lib. I started my code with a Atmel AT91Lib example for Keil. The board_cstartup_keil.s explicitly says, it supports nested interrupts.
My code is C++ with many static classes, using the C-functions from the AT91Lib via extern "C".

And here is my problem:
At the moment, I have 2 interrupts enabled. CAN-event-handler and 10ms-PIT. When both are having the same priority (== no nesting), everything works fine. When the CAN gets a higher priority, the core hangs up here and then (few seconds to minutes).
Debugger says: Mode: undefined, PC points to 0x4 (undefVector).
When stepping through the code, this happens when returning from a function that's called from a interrupt handler.

So my idea is, that there is a problem with the return-address when trying to return to the calling interrupt handler function. Any idea how to solve this? If you need more info, just tell me.

Greetings from Germany,
Thomas


Top
 Profile  
 
 Post subject: Re: Nested Interrupts on SAM7X with AT9Lib & Keil µVision
PostPosted: Fri Nov 11, 2011 6:58 pm 
Offline

Joined: Sat Oct 30, 2010 6:04 pm
Posts: 574
Check that you're not overflowing the stack. Understand how big/where your stacks are, fill them with a visible pattern so you can observed worse case usage patterns.

Check that you have no re-entrance issues.


Top
 Profile  
 
 Post subject: Re: Nested Interrupts on SAM7X with AT9Lib & Keil µVision
PostPosted: Sun Nov 20, 2011 4:24 pm 
Offline

Joined: Thu Nov 03, 2011 11:55 am
Posts: 2
Location: Ulm, Germany
Problem solved. It was a stack problem, caused by different addresshandling.

The board_cstartup_keil.s initialized the irq-stack to 0x220000 (ram-end) and the supervisor-stack to 0x21F800 (ram-end - irq-stack-size).
The asm-code somewhere between __main and the real main-function, which copies the startup-values for static variables and stuff, changes the supervisor-stack to 0x220000.

So after init, both stacks had the same stack-pointer. I changed the board_cstartup_keil.s to switch both stack-positions.

Thanks for help!


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

All times are UTC + 1 hour [ DST ]


Who is online

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