Keil Logo

Cortex-M Version

Here are a few hints specific for Cortex™-M 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. Interrupt priority grouping can be used with some restrictions specified below.

  • IRQ interrupts are never disabled by RTX Kernel.
  • Software interrupt 0 is used by RTX and cannot be used in your application.
  • RTX uses its own SVC Handler which is automatically linked from the library. If you include another SVC handler (like that found in the SVC.S file) into your project, RTX could fail. Remove any user-created SVC handler from your project to resolve the Hard Fault.
  • When interrupt priority grouping is used, the PRIGROUP must be set before the os_sys_init() function is called. RTX kernel reads the value of PRIGROUP to correctly set internal interrupt pre-emption priorities.
  • The lowest two pre-emption priorities are reserved for RTX kernel, all remaining pre-emption priorities are available to use in your application.
  • Do not change the priority used by the RTX kernel. If this is not avoidable, then ensure that the preempt priority of SysTick/PendSV is lower than SVC.
  • Allowed values for PRIGROUP are from 0 to 6. The PRIGROUP value 7 will cause RTX to fail.
  • Check the Main Stack size configured from the startup file if you see sporadic crashes of your application. The RTX Kernel for Cortex™-M is implemented as a System Service Calls. All SVC calls use a Main Stack.

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 Main Stack is used.

Stack size used by RTX kernel is configured in STARTUP.S. Minimum size is 128 bytes, however 256 bytes is recommended when interrupts are used.

Main stack is also used when SVC functions are called. If you are using your own complex __svc functions, you might also need to increase the size of this stack.

You can initialize simple IO, like configure the port pins and enable AD converter, enable interrupts, before the os_sys_init() function is called. The init_IO() function is executed in privileged mode. It is recommended to configure peripherals in this function and use unprivileged mode for the tasks.

void main (void) {
  /* Here a simple IO may be initialized. */
  init_IO ();
   os_sys_init (task1);
  /* The code execution should never reach this point. */
  for (;;);
}
  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.