这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 嵌入式开发 » MCU » [求助]关于vxworks的中断

共4条 1/1 1 跳转至

[求助]关于vxworks的中断

菜鸟
2006-05-07 02:15:21     打赏

相信很多人都看过以下这段代码:

/* includes */
#include "vxWorks.h"
#include "intLib.h"
#include "taskLib.h"
#include "sysLib.h"
#include "logLib.h"

/* function prototypes */
void interruptHandler(int);
void interruptCatcher(void);

/* globals */
#define INTERRUPT_NUM 2
#define INTERRUPT_LEVEL 65
#define ITER1 40
#define LONG_TIME 1000000
#define PRIORITY 100

#define IVEC_TO_INUM(intVec) ((int) (intVec))
#define INUM_TO_IVEC(intNum) ((VOIDFUNCPTR *) (intNum))



void interruptGenerator(void) /* task to generate the SIGINT signal */
{
int i, j, taskId;
STATUS taskAlive;

if ((taskId = taskSpawn("interruptCatcher", PRIORITY, 0x100, 20000, (FUNCPTR)
interruptCatcher, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) == ERROR)
logMsg("taskSpawn interruptCatcher failed\n", 0, 0, 0, 0, 0, 0);


for (i = 0; i < ITER1; i++)
{
taskDelay(1); /* suspend interruptGenerator */
/* check to see if interruptCatcher task is alive! */
if ((taskAlive = taskIdVerify(taskId)) == OK)
{
logMsg("++++++++++++++++++++++++++Interrupt generated\n", 0, 0, 0, 0, 0,
0);
/* generate hardware interrupt 2 */
if ((sysBusIntGen(INTERRUPT_NUM, INTERRUPT_LEVEL)) == ERROR)
logMsg("Interrupt not generated\n", 0, 0, 0, 0, 0, 0);
}
else
/* interruptCatcher is dead */
{
logMsg("interruptCatcher is dead\n", 0,0,0,0,0,0);
break;
}
}

logMsg("\n***************interruptGenerator Exited***************\n\n\n\n", 0,
0, 0, 0, 0, 0);
}

void interruptCatcher(void) /* task to handle the interrupt */
{
int i, j;
STATUS connected;

/* connect the interrupt vector, INTERRUPT_LEVEL, to a specific interrupt
handler routine ,interruptHandler, and pass an argument, i */
if ((connected = intConnect(INUM_TO_IVEC(INTERRUPT_LEVEL), (VOIDFUNCPTR)
interruptHandler, i)) == ERROR)
logMsg("intConnect failed\n", 0, 0, 0, 0, 0, 0);

for (i = 0; i < ITER1; i++)
{
taskDelay(1);
for (j = 0; j < LONG_TIME; j++)
;
logMsg("Normal processing in interruptCatcher\n", 0, 0, 0, 0, 0, 0);
}

logMsg("\n+++++++++++++++interruptCatcher Exited+++++++++++++++\n", 0, 0, 0,
0, 0, 0);
}

void interruptHandler(int arg) /* signal handler code */
{
int i;
logMsg("-------------------------------interrupt caught\n", 0, 0, 0, 0, 0, 0);
for (i = 0; i < 5; i++)
logMsg("interrupt processing\n", 0, 0, 0, 0, 0, 0);
}


程序是在simnt上跑的。当调用sysBusIntGen产生中断时会出错,无法激活ISR,问题出在哪儿呢,望高手指点,谢谢!




关键词: 求助     关于     vxworks     中断     logMsg    

菜鸟
2006-05-07 04:23:00     打赏
2楼
simnt上面好像不能访问这些硬件中断。

菜鸟
2006-05-07 04:52:00     打赏
3楼

噢?我以为这是个像消息一样的软中断呢


菜鸟
2006-05-10 17:41:00     打赏
4楼
在simulator上不能操作中断。用消息队列吧。

共4条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]