Corrupted value in register after interrupt on LPC2368

Hello,

I’ve hit a wall guys…

My problem is as follows:

  1. all the processes run normally

  2. then external interrupt occures

  3. I handle it with eint3 handler (external interrupt 3)

  4. after returning form eint3 handler sometimes - not always -

r4 register containes corrupted value. Insted of containing value

which was in before the eint3 interrupt it contains - as it seems -

the value of stack pointer of user mode

Any ideas?

for clearifing my point

void main(void)
{
   while(1)
   {
     /*some code*/
     results_process(); --> eint3handler()
                                     {
                                       /*some code*/
                                platform_powerdown()-->application_powerdown();
                                       /*end of eint3 handler*/
                                     }
   /*register r4 gets corrupted sometimes*/
   }
 
}

I use RVCT 2.2

All the code is written in THUMB mode, except for eint3_handler which is in ARM mode.

best regards

uros

Hi uros

Try increasing the IRQ stack size - it may be that the IRQ is overrunning its stack space and this can cause corruption of the system mode stack, resulting in it popping corrupted register values.

This is also compiler optimization dependent. An IRQ with full optimization enabled may use almost exclusively internal registers, but the same without optimization may use a lot of stack for its variable use. This means that enabling optimization will often ‘cure’ such problems too. However the IRQ stack use, in worst case, should be known to ensure that its defined stack size if really adequate.

Regards

Mark

http://www.uTasker.com