4

I'm currently using IAR Embedded Workbench to do development for an NXP LPC2378 micro. I think I'm running into issues where my IRQ and CSTACK need to be bigger since the CPU keeps crashing and I noticed that these regions would "bleed" over into surrounding memory areas. I guess I dont really understand what these and the other regions of memory are used for? I use an RTOS (CMX) which reserves RAM for the ISR, but this seems like its for something different.

What are the IRQ_STACK, CSTACK, SVC_STACK, FIQ_STACK, UND_STACK, and ABT_STACK used for when I am using an RTOS, or are they something separate entirely?

Seidleroni
  • 1,044
  • 3
  • 15
  • 31
  • From the top of my head, IRQ, SVC, FIQ, UND registers depend on the current ARM mode. Make sure those registers are available in your current mode so that regions don't bleed over. – Anon Nov 09 '12 at 01:18
  • Anon, they are available, but what are they used for (in the general sense)? – Seidleroni Nov 09 '12 at 01:37
  • User : unprivileged mode under which most tasks run FIQ : entered when a high priority (fast) interrupt is raised IRQ : entered when a low priority (normal) interrupt is raised Supervisor : entered on reset and when a Software Interrupt instruction is executed Abort : used to handle memory access violations Undef : used to handle undefined instructions System : privileged mode using the same registers as user mode – Anon Nov 09 '12 at 01:45
  • Read up on ARM7TDMI: http://infocenter.arm.com/help/topic/com.arm.doc.ddi0210c/DDI0210B.pdf – starblue Nov 13 '12 at 22:03

1 Answers1

5

LPC23XX have a few different modes. Each mode has its own stack. Things like interrupts involve switching mode by saving the context registers (to the current mode's stack, I believe) before switching to a different mode, among other things.

That you are using an RTOS doesn't change the purpose of these stacks, but sometimes RTOSes may have requirements about them (you might want to look this up for CMX).

  • IRQ_STACK - Interrupt (IRQ) mode stack.
  • CSTACK - User and system modes stack. This is your regular stack for code execution most of the time.
  • SVC_STACK - Supervisor mode stack. Some instructions can only be run in SVC mode. IIRC the CPU starts in this mode and drops out of it after the initial setup has been done.
  • FIQ_STACK - FIQ interrupt mode stack. Fast interrupts (FIQs) can occur during an IRQ - they're like a higher priority IRQ. FIQs and IRQs are disabled when in a FIQ.
  • UND_STACK Undefined instruction mode stack.
  • ABT_STACK Abort mode stack, for data aborts and so on. (You can set up handlers to run when an abort is triggered.)

I'm not familiar with IAR, but if these are sizes then they are equivalent to UND_Stack_Size, SVC_Stack_Size, ABT_Stack_Size, FIQ_Stack_Size, IRQ_Stack_Size, and USR_Stack_Size in uVision. ISR_Stack_Size or equivalent should be the sum of the first five.

Remember, overflowing the stack(s) makes bad things happen. You quite possibly need to make your stack(s) larger, but like I said, you probably need to look up the min. required values for CMX.

Iskar Jarak
  • 5,136
  • 4
  • 38
  • 60
  • A good explanation, but one more question that might help me. What are these stacks storing? Are they storing the the call stack and the local variables throughout the call stack or are they doing something different? – Seidleroni Nov 09 '12 at 02:25
  • @Seidleroni, these stacks , irrespective of the mode will store link register, stack pointer , program counter (pc) and current program status register (cpsr). Barring FIQ mode,they also have 13 registers to store local variables etc. FIQ mode has 8 registers to store local variables. – Anon Nov 09 '12 at 02:35
  • First, yes, they are the call stacks for the relevant modes, so they do store your local variables. Second, that's not necessarily _all_ they store (e.g. when you mode/context switch other data such as context registers gets pushed to the stack). See also http://en.wikipedia.org/wiki/Calling_convention#ARM for some info about where the LR, SP, PC, and CPSR are stored. – Iskar Jarak Nov 09 '12 at 02:44