DSPRelated.com
Forums

linear assembly, SP and NMI

Started by Bernhard 'Gustl' Bauer December 5, 2008
Hi,

I'm using NMI as power fail interrupt, to save important vars. Sometimes
this didn't work.

After a lot of debugging I found out why - the SP is sometimes corrupt!
More debugging lead me to a linear assembly routine which is translated
into code that uses the SP. IRP is saved to stack and SP is saved to
IRP. As long as this code isn't interrupted all works fine. During
normal operation this won't happen, because this code is used in a IRQ
routine.

BUT NMI can interrupt IRQs! My pdown code is written in C and therefore
uses SP which is not reliable in this case.

I solved this problem by explicit setting SP to a valid value before
entering pdown C code. This works for me because after NMI SP isn't used
anymore. But this issue may cause problems when using NMI as periodic IRQ.

I'm using CCS 2.2 and wondering if this is still the same in CCS 3.3?

Interested in your comments.

Gustl