This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Interrupt stacking issues


I think I've got some understanding of why I'm seeing my stack
overflow, and I'm not quite sure what to do about it.  I think that
this describes the circumstances:

1 A character arrives at the serial port, triggering the ISR.
2 The ISR runs to completion, signalling the PendSV handler.
3 The PendSV handler pushes a "fake" stack frame onto the stack of the
executing thread, adding hal_interrupt_end and hal_interrupt_end_done
into the backtrace.
4 PendSV exits, returning the processor to its normal mode, but
running hal_interrupt_end.
5 hal_interrupt_end ultimately results in DSRs being called.
6 Normal thread execution is resumed.

I think that the problem might occur if another interrupt arrives
while step 4 is occurring.  There is an extra frame on the stack, but
all the interrupts (and PendSV) have run and are capable of being
re-run.  If another interrupt arrives at this point, the ISR/PendSV
runs again, and _another_ fake frame is pushed to the stack.  A series
of evenly spaced interrupts (such as one would find in a serial
stream) will push fake frames to the stack until overflow.  I could
disable serial interrupts in the ISR and re-enable in the DSR, but
that defeats the object of the STM32 serial driver copying data into
an intermediate buffer in the ISR.  This would also be affected by any
other unfortunately timed interrupts.

If I've understood this right, one doesn't just need to size stacks
based on the number of simultaneously triggered ISRs that might occur,
but also on the number that might occur in a row one after another.

I really hope that either a) I've misunderstood the issue, or b) I've
missed an obvious fix.

Can anyone confirm that I've understood this, or suggest any options?

Thanks

Alan

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]