Keil Logo

ARM7/ARM9 Version

Here are a few hints specific for ARM7™/ARM9™ library version.

Using IRQ interrupts

You can use IRQ interrupts with no limitation. RTX kernel uses only one timer interrupt to generate periodic timer ticks and activate the task scheduler.

  • IRQ interrupts are disabled by RTX for a very short time (a few µseconds maximum).
  • RTX kernel uses Software Interrupts to protect a critical code section from interrupts.
  • Software interrupts 0-7 are used by RTX and cannot be used in your application.
  • RTX uses its own SWI Handler which is automatically linked from the library. If you include another SWI handler (like that found in the SWI.S file) into your project, RTX could fail. Remove any user-created SWI handler from your project to resolve the Data Abort.
  • Check the IRQ stack size configured from the startup file if you see sporadic crashes of your application. The IRQ stack usage depends on the complexity of your additional interrupt functions.

Using FIQ interrupts

ARM7™/ARM9™ Fast Interrupts are not used by the RTX kernel. You may freely use FIQ interrupts in you application in parallel with the kernel.

  • FIQ interrupts are never disabled by RTX.
  • You cannot call any kernel system function from the FIQ Interrupt Handler.

System Startup

RTX kernel uses a separate stack for each task it creates. The stack size is configured in the configuration file. However, before the kernel is started by the os_sys_init() function, the stack that is configured in the startup file STARTUP.S for the User Mode is used. When the RTX kernel is up and running, the User Mode stack is used for the task manager - an RTX task scheduler.

Minimum stack sizes for RTX kernel configured in STARTUP.S are:

  • Supervisor Mode 32 bytes (0x00000020)
  • Interrupt Mode 64 bytes (0x00000040)
  • User Mode 80 bytes (0x00000050)

Supervisor Mode stack is used when SWI functions are called. If you are using your own complex __swi functions, you might also need to increase the size of this stack.

Interrupt Mode stack is used on timer tick interrupts. This interrupt activates the system task scheduler. The scheduler uses the User/System Mode stack defined in STARTUP.S and runs in System Mode. If you are using interrupts in your application, you should increase the size of the Interrupt Mode stack. A stack size of 256 bytes is a good choice for a start. If the interrupt stack overflows, the application might crash.

User Mode stack is used until the kernel is started. It is better to initialize the user application from the first task which is created and started by the os_sys_init() function call.

You can initialize simple IO, like configure the port pins and enable AD converter, before the os_sys_init() function is called. The init_IO() function must be small and must not use many local variables because the User Mode stack can overflow otherwise.

void main (void) {
  /* Here a simple IO may be initialized. */
  init_IO ();
  os_sys_init (task1);
  /* The program execution shall never reach this point. */
  for (;;);
}

It is better to do a complex initialization from the first task that starts. In this case, the stack for this task is used, which is in general much bigger than User Mode stack.

__task void task1 (void) {
  /* Here the interrupts and more complex IO may be initialized. */
  Init_CAN ();
   ..
}

Related Knowledgebase Articles

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.