Keil Logo

RTX51: USING THE OS_ENABLE_ISR FUNCTION


Information in this article applies to:

  • RTX51 Version 5.10b

QUESTION

How do I create an interrupt service routine in RTX51?

ANSWER

Using interrupt service routines in RTX51 is pretty straight-forward.

  1. Create the interrupt service routine as you would in a standard Keil C51 program. This is the int0 function in the following example.
  2. Create some code that enables the interrupt source. The statements EX0 = 1; and IT0 = 1; in the startup task do this.
  3. Call the os_enable_isr function and pass the interrupt number. This is also done in the startup task.

For example:

#include <rtx51.h>
#include <reg51.h>
#include <stdio.h>

#define STARTUP_TASK 0

//-----------------------------------------------
//-----------------------------------------------
void int0 (void) interrupt 0
{
static unsigned int i;

i++;
}

//-----------------------------------------------
//-----------------------------------------------
void task0 (void) _task_ STARTUP_TASK
{
os_set_slice (1000);        /* Set for OSC Frequency / 10,000 */

EX0 = 1;                    /* Enable External Int 0 */
IT0 = 1;                    /* Edge-triggered */

os_enable_isr (0);          /* Enable interrupt #0 */


while (1)
  {
  os_wait (K_TMO, 100, NULL);
  }
}
//-----------------------------------------------
//-----------------------------------------------
void main (void)
{
os_start_system (STARTUP_TASK);
}

MORE INFORMATION

You may download this complete RTX51 example for µVision from the Keil website.

Last Reviewed: Thursday, September 22, 2005


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  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.