| |||||
Technical Support Support Resources
Product Information | RTX51: USING THE OS_ENABLE_ISR FUNCTIONInformation in this article applies to:
QUESTIONHow do I create an interrupt service routine in RTX51? ANSWERUsing interrupt service routines in RTX51 is pretty straight-forward.
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 INFORMATIONYou may download this complete RTX51 example for µVision from the Keil website. Last Reviewed: Thursday, September 22, 2005 | ||||