Help with Interrupts / Stack error                (MCF5282EVB)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Help with Interrupts / Stack error                (MCF5282EVB)

2,276 Views
francois_boucha
Contributor III
Hi all,
I m doing a simple timer project where I need DMA timer 0 to triggers an interrupt.  It works but very badly.
As you can see in the image I attached, the stack is going crazy as it does some weird routines, and
does not unstack.   The exception I get is CASE 14: Format error StackFramePC.

Can someone tell me what could be wrong?
FB
Labels (1)
0 Kudos
Reply
6 Replies

616 Views
francois_boucha
Contributor III
Thanks both, but there is still something weird going on.

Now the interrupt routines are executed, at least in the internal SRAM (mcf5282).  It rolls fine.  But when I flash the code, the same interrupt routine is'nt triggerd at all.  Its weird because in the SRAM, it is working, bit in the Internal FLASH,  the Interrupt routine are'nt showing.  We checked the mask register, the SR, ... everything seems ok.  What could be wrong?

/**************************************************************************
FUNCT: ref_reached_interrupt
***************************************************************************/

__declspec(interrupt:0)
void ref_reached_timer_isr(void)
{
   

    /* Clears the event flags */
    MCF_DTIM_DTER(0) =  (0 |MCF_DTIM_DTER_CAP | MCF_DTIM_DTER_REF);
   
   
    ++Seconds[0];
}


thanks
FB
0 Kudos
Reply

616 Views
SimonMarsden_de
Contributor II
OK, just a guess... but maybe the exception vector table is not set up correctly?

Also, I did notice from the screen snapshot you posted, that you are calling the interrupt service routine in a slightly unusual way. Nothing wrong with it, but it's not the normal way to do things...

You appear to have all interrupts handled initially by a single routine 'asm_exception_handler', which is then checking the exception number and calling your interrupt-specific routine 'ref_reached_timer_isr'.

A more common way to do this would be to plug the appropriate interrupt-specific entry in the exception vector table, so that when the interrupt happens 'ref_reached_timer_isr' is called directly. The table entry should contain a pointer to your ISR. If the exception vector table is in Flash, the pointer will need to be assembled in.

Hope this helps.


Simon
0 Kudos
Reply

616 Views
francois_boucha
Contributor III




Also, I did notice from the screen snapshot you posted, that you are calling the interrupt service routine in a slightly unusual way. Nothing wrong with it, but it's not the normal way to do things...
...

Simon



You are right about it, and thanks by the way.  The way the interrupt routine is called is'nt very ...efficient.

So that has been corrected.  The isr is now located in the vector table of the exception.c file.



Simon Marsden wrote:
...

A more common way to do this would be to plug the appropriate interrupt-specific entry in the exception vector table, so that when the interrupt happens 'ref_reached_timer_isr' is called directly. The table entry should contain a pointer to your ISR. If the exception vector table is in Flash, the pointer will need to be assembled in.

Hope this helps.

Simon




And finally, maybe in Flash, the isr is'nt called.  So what should Ido to be sure that my isr entry in the vector table is good ?

should I use this function?
interrupt_init(uint8 source, uint8 ipl, void (*handler)(void));

many thanks,
Francois


0 Kudos
Reply

616 Views
francois_boucha
Contributor III
Hi,
SO I was'nt calling the routine from the right place, and now the problem is fixed. 

By the way, could anyone please tell me why is the 0 needed (or maybe not ? ) in this:

            __declspec(interrupt :0)

Thanks
FB
0 Kudos
Reply

616 Views
SimonMarsden_de
Contributor II
Hi

For a discussion of __declspec, see this posting.

http://forums.freescale.com/freescale/board/message?board.id=CFCOMM&message.id=2016&query.id=17833#M...


Hope this helps


Simon
0 Kudos
Reply

616 Views
JimDon
Senior Contributor III
Rather than guess what might be wrong, why don't post the set up code and the interrupt  handler code?

You did put the address of the handler in the table?

0 Kudos
Reply