Tc222 multican interrupts

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User16898
Level 4
Level 4
Hi,
are there any sample codes for multican interrupts?
0 Likes
2 Replies
User16898
Level 4
Level 4
I have configured general can config:
canConfig.nodePointer[IfxMultican_SrcId_0].priority =CAN_RX_INERRUPT_PRIORITY;
canConfig.nodePointer[IfxMultican_SrcId_0].typeOfService =IfxSrc_Tos_cpu0;


and then node needs to be configured:
	canNodeConfig.transferInterrupt.enabled = TRUE;
canNodeConfig.transferInterrupt.srcId = IfxMultican_SrcId_0;


then message objects needs to be configured:
canMsgObjConfig.rxInterrupt.enabled = TRUE;
canMsgObjConfig.rxInterrupt.srcId = IfxMultican_SrcId_0;


and have several question:
1. what nodePointer array is
2. what is transfer interrupt in can node config is and where can i configure node rx and tx interrupt ?
0 Likes
NeMa_4793301
Level 6
Level 6
10 likes received 10 solutions authored 5 solutions authored
Hi Lukas_G. The nodePointer array configures how each CAN node's service requests are sent to the Interrupt Router. It's used inside of IfxMultican_Can_initModule():

    /* Configure interrupt node pointers */
IfxMultican_SrcId srcId;

for (srcId = 0; srcId < IFXMULTICAN_NUM_SRC; srcId++)
{
volatile Ifx_SRC_SRCR *srcPointer = IfxMultican_getSrcPointer(mcanSFR, srcId);
IfxSrc_init(srcPointer, config->nodePointer[srcId].typeOfService, config->nodePointer[srcId].priority);

if (config->nodePointer[srcId].priority)
{
IfxSrc_enable(srcPointer);
}

To declare the interrupt handler in your code, do something like this:

IFX_INTERRUPT(ISR_can0_rx, 0, CAN_RX_INERRUPT_PRIORITY); // maybe INTERRUPT instead of INERRUPT 😉

void ISR_can0_rx(void)
{
IfxCpu_enableInterrupts();
IfxMultican_Message msg1;
IfxMultican_Message_init(&msg1, 0xdead, 0xdeadbeef, 0xdeadbeef, IfxMultican_DataLengthCode_8); /* start with invalid values */
IfxMultican_Status readStatus = IfxMultican_Can_MsgObj_readMessage(&g_MulticanBasic.drivers.canDstMsgObj, &msg1);
if ( readStatus & IfxMultican_Status_newData)
{
// handle new message here in msg1.data[]
}
}
0 Likes