请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
器件型号:TMS320C6678 我修改了 IPC 中断示例项目上的一些代码、首先 Core0向 Core1发送 IPC 中断、然后 Core1发送到 Core2、从而最终 Core7向 Core0发送中断。
在这种情况下、每个内核都应调用 ISR、但在本项目中、某些内核会调用多个 ISR。 问题出在哪里?
中断功能和主功能如下:
#include #include #include #include #include #include #include #include #include "ipc_interrupt.h" void main (void){ uint32_ti; uint32_tcnt = 0; uint32_tCoreID = CSL_chipReadReg (CSL_chip_DNUM); TSCL=0; intcInit(); registerInterrupt (); for (i=0; i<1000;i++) { cnt += 1; } if (CoreID =0) { IssueInterruptToNextCore (); } while (1) { cnt += 1; }
#ifndef IPC_INTERRUPT_H_ #define IPC_INTERRUPT_H_ #define MAX_CORE_NUM (8) #define MAX_SYSTEM_VECTOR (8) #define MAX_CORE_VECTOR (12) /******** 用户定义**** / #define RENUM 8 #define IPCIPCGR0(0x02620240u) #define IPCGR1(0x02620244u) #defineIPCGR2(0x02620248u) #define IPCGR3(0x0262024Cu) #define IPCGR4(0x02620250u) #define IPCGR5(0x02620244u)#define IPCAR202620244 (0x026202620262024u)#define (0x02620262026202620242)#define ARIPCAR-026202620242)#define (0x02620262026202620242)#define (0x026202620262026202620242)#define ARARIPCARIPCAR-02620242 (0x026202620262026202620246 #define)#define (026202620262026202620242 )#define (026202620262026202620262026202620242)#define (0262026 intc_EventID_IPC_LOCAL (91) typedef 结构 { uint32_t core; // CoreID uint32_t 事件; // intc 事件 CSL_IntcVectId vect;//核心中断矢量 CSL_IntcEventHandler ISR; }断流 Cfg; int32_t intcInit(); int32_t registerInterrupt(); void NextIssueInterruptToCore(); void IPC_ISR (); #endif /* IPC_INTERRUPT_H_*/
#include
#include
#include
#include
#include
#include
#include
#include "IPC_INTERRUPT.h"
CSL_IntcGlobalEnableState;
CSL_IntcContext;
CSL_IntcEventHandlerRecord [CSL_INTC_EventID_CNT];
CSL_IntcEventHandlerRecord EventRecord;
UINT32_t coreVector[MAX_CORE_NUM];
CSL_IntcObj intcObj[16];
CSL_IntcHandle hintc[16];
volatile UINT32 interruptNumber=0;
/* IPCGR Info */
Int32_t iGRInfo[CORNUM]={
IPCGR0、
IPCGR1、
IPCGR2、
IPCGR3
、IPCGR4、IPCGR4
IPCGR5、
IPCGR6、
IPCGR7
};
//* IPCAR 信息*/
int32_t iIPCARInfo[CORUM]={
IPCAR0、
IPCAR1、
IPCAR2、
IPCAR3、
IPCAR4、
IPCAR5、
IPCAR6、
IPCAR7
};
interruptCfg intInfo[MAX_SYSTEM_VECTOR ]=
{
//*核心事件矢量*/
{0、 91、 CSL_INTC_VECTID_4、&IPC_ISR}、
{1、 91、 CSL_INTC_VECTID_4、&IPC_ISR}、
{2、 91、 CSL_INTC_VECTID_4、&IPC_ISR}、
{3、 91、 CSL_INTC_VECTID_4、&IPC_ISR}、
{4、 91、 CSL_INTC_VECTID_4、&IPC_ISR}、
{5、 91、 CSL_INTC_VECTID_4、&IPC_ISR}、
{6、 91、 CSL_INTC_VECTID_4、&IPC_ISR}、
{7、 91、 CSL_INTC_VECTID_4、&IPC_ISR}、
};
int32_t intcInit()
{
/* INTC 模块初始化*/
context.eventhandlerRecord =记录;
context.numEvtEntry = CSL_INTC_EventID_CNT;
if (CSL_intcInit (&context)!= CSL_Sok)
返回-1;
/*启用 NMI */
if (CSL_intcGlobalNmiEnable ()!= CSL_SOK)
返回-1;
/*启用全局中断*/
if (CSL_intcGlobalEnable (&state)!= CSL_SOK)
返回-1;
/* INTC 已成功初始化。 *
返回0;
}
int32_t registerInterrupt ()
{
uint32_t i;
uint32_t event;
uint32_t vector;
uint32_t core;
uint32_t CoreID = CSL_chipReadReg (CSL_CHIP_DNUM);
CSL_IntcEventInfo ISR;
for (i=0;i=i+[intcoreID]
=
i
);[intcortore+= 0+= eintcortoreID](i+<intcortore+= vector.i+);t = intcortoreID=v0+= int+[intcortore+= intcortore+);
ISR = intInfo[i].ISR;
if (MAX_CORE_VECTOR <= coreVector[CORE])
{
printf ("内核%d 矢量编号超过\n");
}
hintc[矢量]= CSL_intcOpen (&intcObj[矢量],事件,(CSL_IntcParam*)&vector,NULL);
if (hintc[矢量]== NULL)
{
printf ("错误:gem - intc 打开失败\n");
返回-1;
}
/*注册在事件发生时调用的回调处理程序。 *
EventRecord.handler = ISR;
EventRecord.arg = 0;
if (CSL_intcPlugEventHandler (hintc[vector]、&EventRecord)!= CSL_Sok)
{
printf ("错误:gem-intc 插头事件处理程序失败\n");
返回-1;
}
/*清除事件。 *
if (CSL_intcHwControl (hintc[矢量]、CSL_INTC_CMD_EVTCLEAR、NULL)!= CSL_SOK)
{
printf ("错误:gem-intc CSL_intc_cmd_evtclear 命令失败\n");
返回-1;
}
/*启用事件。 *
if (CSL_intcHwControl (hintc[矢量]、CSL_INTC_CMD_EVTENABLE、NULL)!= CSL_SOK)
{
printf ("错误:gome-intc CSL_intc_cmd_EVTENABLE 命令失败\n");
返回-1;
}
coreVector[core]++;
}
}
返回0;
}
//引导和配置 DSP 系统模块定义
#define CHIP_LEVEL_REG 0x02620000
//引导 cfg 寄存
器#define KICK0*(unsigned int*)(CHIP_LEVEL_REG + 0x0038)
#define KICK1*(unsigned int*)(CHIP_LEVEL_LEVEL_LEVEL_INTRU32
)#define KICKINTRU32
(define 0xEINTRU32)#define NEUTRUTRUTRU32 INT0 (#define NEUTRUTRU32) INTRUTRUTRU32 INTRUTRUTRUTRUTRUTRUTRUTRU32 INT0 IN32_INTRUTRUTRUTRUTRUTRU32 (
CoreNum = CSL_chipReadReg (CSL_CHIP_DNUM);
iNextCore =(CoreNum + 1)%8;//
printf ("将中断从内核%x 设置为内核%d、cycle =%d\n"、CoreNum、iNextCore、TSCL);
interruptInfo +=16;
//解锁配置
KICK0 = KICK0_UNLOCK;
KICK1 = KICK1_UNLOCK;
*(volatile UINT32_t *) iNITGRInfo[iNextCore]= interruptInfo;
*(volatile UINT32_t *) iPCGRInfo[iTUNLOCK = 1;
// IPCK0
= IDR0
;
void IPCK_UNLOCK = ICP0;ICP0 = IPCK0;ICP1
uint32_t CoreNum;
uint32_t iPrevCore;
CoreNum = CSL_chipReadReg (CSL_CHIP_DNUM);;
iPrevCore =(CoreNum - 1)%8;
READ_ipcgr =*(volatile UINT32 *) iIPCGRInfo[CoreNum];
*(volatile uint32_t *) iIPCARInfo[CoreNum]= read_ipcgr;//清除相关源信息
printf ("从内核%d 接收包含信息0x%x 的中断、cycle =%d\n"、iPrevCore、READ_ipcgr、TSCL);
interruptNumber++;
if (CoreNum!=0)//
{
IssueInterruptToNextCore();
}
其他
{
printf ("IPC 测试通过!\n");
}
}
结果为: