Announcements

Equip yourself to optimize AURIX™ MCUs for Evs at the EV Webinar. Click here to register.

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

AURIX™ Forum Discussions

User20311
Level 1
Level 1
10 replies posted 5 replies posted 5 questions asked

#define ISR_PRIORITY_CAN_TX 10 /* Define the CAN TX interrupt priority */
#define ISR_PRIORITY_CAN_RX 11 /* Define the CAN RX interrupt priority */
#define NODE0_RAM_OFFSET 0x0
#define NODE1_RAM_OFFSET 0x1000
#define NODE2_RAM_OFFSET 0x2000
#define NODE3_RAM_OFFSET 0x3000

#define CAN_MESSAGE_RX_ID1 0x700
#define CAN_MESSAGE_RX_ID2 0x7DF
IFX_INTERRUPT(canIsrRxHandler, 0, ISR_PRIORITY_CAN_RX);
void canIsrRxHandler(void)
{
while(1);//test!!!! breakpoint
}
IFX_CONST IfxCan_Can_Pins Can11_pins = {
&IfxCan_TXD11_P02_5_OUT, IfxPort_OutputMode_pushPull, // CAN11_TX
&IfxCan_RXD11A_P02_4_IN, IfxPort_InputMode_pullUp, // CAN11_RX
IfxPort_PadDriver_cmosAutomotiveSpeed4
};
void InitCan1Node1(void)
{

IfxCan_Can_initModuleConfig(&g_mcmcan.canConfig, &MODULE_CAN1);
IfxCan_Can_initModule(&g_mcmcan.canModule, &g_mcmcan.canConfig);

/*******CAN1 node1 configuration and initialization*******/
IfxCan_Can_initNodeConfig(&g_mcmcan.canNodeConfig, &g_mcmcan.canModule);

g_mcmcan.canNodeConfig.nodeId = IfxCan_NodeId_1;
g_mcmcan.canNodeConfig.clockSource = IfxCan_ClockSource_both;
g_mcmcan.canNodeConfig.frame.type = IfxCan_FrameType_transmitAndReceive;
g_mcmcan.canNodeConfig.frame.mode = IfxCan_FrameMode_standard; //Classic CAN

g_mcmcan.canNodeConfig.txConfig.txMode = IfxCan_TxMode_dedicatedBuffers;
g_mcmcan.canNodeConfig.txConfig.dedicatedTxBuffersNumber = 16;
g_mcmcan.canNodeConfig.txConfig.txBufferDataFieldSize = IfxCan_DataFieldSize_8;

g_mcmcan.canNodeConfig.rxConfig.rxMode = IfxCan_RxMode_dedicatedBuffers;
g_mcmcan.canNodeConfig.rxConfig.rxBufferDataFieldSize = IfxCan_DataFieldSize_8;

g_mcmcan.canNodeConfig.filterConfig.messageIdLength = IfxCan_MessageIdLength_standard;
g_mcmcan.canNodeConfig.filterConfig.standardListSize = 10; //Standard Frame
g_mcmcan.canNodeConfig.filterConfig.extendedListSize = 0; //Extended Frame
//g_mcmcan.canNodeConfig.filterConfig.rejectRemoteFramesWithStandardId = TRUE;
//g_mcmcan.canNodeConfig.filterConfig.rejectRemoteFramesWithExtendedId = TRUE;
g_mcmcan.canNodeConfig.filterConfig.standardFilterForNonMatchingFrames = IfxCan_NonMatchingFrame_reject;
g_mcmcan.canNodeConfig.filterConfig.extendedFilterForNonMatchingFrames = IfxCan_NonMatchingFrame_reject;


g_mcmcan.canNodeConfig.messageRAM.standardFilterListStartAddress=0x100+NODE1_RAM_OFFSET;///?
g_mcmcan.canNodeConfig.messageRAM.rxBuffersStartAddress =0x200+NODE1_RAM_OFFSET;//?
g_mcmcan.canNodeConfig.messageRAM.txBuffersStartAddress =0x400+NODE1_RAM_OFFSET;//?
g_mcmcan.canNodeConfig.messageRAM.baseAddress = (uint32)&MODULE_CAN1,//MODULE_CAN1+NODE1_RAM_OFFSET;

g_mcmcan.canNodeConfig.baudRate.baudrate = 500000; //500KBaud

//transmit interrupt
g_mcmcan.canNodeConfig.interruptConfig.transmissionCompletedEnabled = TRUE;
g_mcmcan.canNodeConfig.interruptConfig.traco.priority = ISR_PRIORITY_CAN_TX;
g_mcmcan.canNodeConfig.interruptConfig.traco.interruptLine = IfxCan_InterruptLine_0;
g_mcmcan.canNodeConfig.interruptConfig.traco.typeOfService = IfxSrc_Tos_cpu0;

//receive interrupt
g_mcmcan.canNodeConfig.interruptConfig.messageStoredToDedicatedRxBufferEnabled = TRUE;
g_mcmcan.canNodeConfig.interruptConfig.reint.priority = ISR_PRIORITY_CAN_RX;
g_mcmcan.canNodeConfig.interruptConfig.reint.interruptLine = IfxCan_InterruptLine_1;
g_mcmcan.canNodeConfig.interruptConfig.reint.typeOfService = IfxSrc_Tos_cpu0;

//binding pin!
g_mcmcan.canNodeConfig.pins = &Can11_pins;

IfxCan_Can_initNode(&g_mcmcan.canSrcNode, &g_mcmcan.canNodeConfig);


/*******CAN filter configuration and initialization*******/
g_mcmcan.canFilter.number = 0;
g_mcmcan.canFilter.elementConfiguration = IfxCan_FilterElementConfiguration_storeInRxBuffer;
g_mcmcan.canFilter.id1 = CAN_MESSAGE_RX_ID1;
//g_mcmcan.canFilter.id2=CAN_MESSAGE_RX_ID2;
g_mcmcan.canFilter.rxBufferOffset = IfxCan_RxBufferId_0;
//IfxCan_Can_setStandardFilter(&g_mcmcan.can00Node, &g_mcmcan.canFilter);
IfxCan_Can_setExtendedFilter(&g_mcmcan.canSrcNode, &g_mcmcan.canFilter);

g_mcmcan.canFilter.number = 1;
g_mcmcan.canFilter.elementConfiguration = IfxCan_FilterElementConfiguration_storeInRxBuffer;
g_mcmcan.canFilter.id1 = CAN_MESSAGE_RX_ID2;
//g_mcmcan.canFilter.id2 = CAN_MESSAGE_RX_ID2;
g_mcmcan.canFilter.rxBufferOffset = IfxCan_RxBufferId_0;
//IfxCan_Can_setStandardFilter(&g_mcmcan.can00Node, &g_mcmcan.canFilter);
IfxCan_Can_setExtendedFilter(&g_mcmcan.canSrcNode, &g_mcmcan.canFilter);

#if 0
g_mcmcan.canFilter.number = 2;
g_mcmcan.canFilter.elementConfiguration = IfxCan_FilterElementConfiguration_storeInRxBuffer;
g_mcmcan.canFilter.id1 = CAN_MESSAGE_RX_ID3;
//g_mcmcan.canFilter.id2 = CAN_MESSAGE_RX_ID3;
g_mcmcan.canFilter.rxBufferOffset = IfxCan_RxBufferId_0;
//IfxCan_Can_setStandardFilter(&g_mcmcan.can00Node, &g_mcmcan.canFilter);
IfxCan_Can_setExtendedFilter(&g_mcmcan.can00Node, &g_mcmcan.canFilter);
#endif
}

sending data is OK and the data could not be received (canIsrRxHandler)
0 Likes
2 Replies
User20311
Level 1
Level 1
10 replies posted 5 replies posted 5 questions asked
5353.attach
image:
0 Likes

I met the same problem, could you tell me how to fix it?

0 Likes