Keil Logo

RTX-ARM Interrupt Functions

While RTX-ARM can work with interrupt functions in parallel, we recommend not using IRQ nesting. Good programming techniques use short interrupt functions that send signals or messages to RTOS tasks. This avoids problems with nested interrupts where the user mode stack usage becomes unpredictable.

An IRQ function may send a signal or message to start an high-priority task. You must use the task interrupt handling with RTX-ARM as illustrated in the following figure:

Interrupt Handling Timeline

Add Keil-style Interrupt Functions to an RTX-ARM application as described in the STR71x Software Library.

The interrupt system is globally enabled by the os_init during execution of the RTX_Config file with the macro OS_TINIT. Therefore, the global interrupt enable is not required.

Periodic Interrupts Example:

vu32 TimeVal;

 * Timer3 IRQ: Executed each 10ms
__irq void T3TIMI_IRQHandler (void) {
  TimeVal++; // Increment Tick Counter
  TIM_FlagClear(TIM3, TIM_TO_IT);
  EIC->IPR = 1 << T3TIMI_IRQChannel;


 * Main: Initialize and start RTX Kernel
void main (void) {
  RCCU_MCLKConfig(RCCU_DEFAULT);                 // MCLK = RCLK
  RCCU_FCLKConfig(RCCU_RCLK_2);                  // FCLK = RCLK/2
  RCCU_PCLKConfig(RCCU_RCLK_4);                  // PCLK = RCLK/4
  RCCU_PLL1Config(RCCU_PLL1_Mul_12, RCCU_Div_2); // 48MHz PLL/16MHz XTAL

  while (RCCU_FlagStatus(RCCU_PLL1_LOCK) == RESET); // Wait for PLL Lock
  RCCU_RCLKSourceConfig(RCCU_PLL1_Output);          // Select RCLK PLL

  // Timer 3 Configuration: Periodic Interrupts at approx. 10ms
  TIM_Init (TIM3);                               // Initialization
  TIM_PrescalerConfig (TIM3, 1);                 // Prescaler
  TIM_ITConfig (TIM3, TIM_TO_IT, ENABLE);        // Enable Overflow Int.
  TIM_CounterConfig (TIM3,TIM_START);            // Start Timer

  // Configure and enable IRQ for Timer 3
  EIC->IVR = (u32)T3TIMI_IRQHandler;
  EIC->SIR[T3TIMI_IRQChannel] = ((u16)T3TIMI_IRQHandler << 16);
  EIC_IRQChannelConfig(T3TIMI_IRQChannel, ENABLE);
  EIC_IRQChannelPriorityConfig(T3TIMI_IRQChannel, 1);

  os_sys_init (init);            // Initialize ARTX and start task 'init'
                                 // will never reach this point
  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.