This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Inline assembly : stack (LPC2478)

Hello,

I'm trying to solve a problem.
I'm using LPC2478

I have the register FIO0MASK that is used in normal routines and interrupt routines.
If a interrupt that changes FIO0MASK value is executed after FIO0MASK set when the interrupt returns the FIO0MASK is not with the correct value.

I'm trying to PUSH FIO0MASK onto stack and after POP FIO0MASK from stack but I don't know how to do this.

How can I push onto stack and pop from stack in inline assembly?

Tnanks

  • Unless you have nested interrupts, it will also work to save the mask to a global variable and have the ISR restore the mask before returning.

    If you design your hardware so that the ISR only needs to access a 8-bit or 16-bit subset, then you may get away with saving a smaller part of the mask. Or you may even manage to have your hw design fully isolate bits used by the ISR and the main application, so that the main application performs 8-bit or 16-bit operations to parts of the port and the ISR performs 8-bit or 16-bit operations to another part of the port.

    Anyway - don't do inline assembly. If you write in C or C++, then just use a local variable on the stack for storing the mask state. The alternative is to write the full ISR in assembler in a separate file.