How to assin CAN port to specific pins?

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

cross mob
leekings
Level 3
Level 3
50 sign-ins 25 replies posted 25 sign-ins

Hello. Infineon team.

I'm Using TC367 MCU and I want to change CAN communication Module and node by using below example code.(i have 2 CAN IC on PCB board)

I tried to changed it, but it doesn't works.

Can you check it where is wrong?

---------------------------------------------------------------------------------------------------------------------

(i think below code is came from loop-back example code)

IfxCan_Can_initModuleConfig(&g_mcmcan.canConfig, &MODULE_CAN1);

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


IfxCan_Can_initNodeConfig(&g_mcmcan.canNodeConfig, &g_mcmcan.canModule);

g_mcmcan.canNodeConfig.busLoopbackEnabled = FALSE;
g_mcmcan.canNodeConfig.nodeId = IfxCan_NodeId_0;
g_mcmcan.canNodeConfig.baudRate.baudrate = 500000;
g_mcmcan.canNodeConfig.frame.type = IfxCan_FrameType_transmit;
g_mcmcan.canNodeConfig.frame.mode = IfxCan_FrameMode_fdLong;

g_mcmcan.canNodeConfig.can->N[0].NPCR.B.RXSEL = 0x3;

g_mcmcan.canNodeConfig.txConfig.txMode = IfxCan_TxMode_dedicatedBuffers;
g_mcmcan.canNodeConfig.txConfig.txBufferDataFieldSize = IfxCan_DataFieldSize_64;

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

---------------------------------------------------------------------------------------------------------------------

when i use above source code, the IC connected to CAN Module 1 / node 3 is works very well(tx:P13.0, rx:P13.1 and it is assigned pinmap assign file)

leekings_0-1674987112028.png

 

i changed bold part as below for using other CAN IC,, 

&MODULE_CAN1 -> &MODULE_CAN0

g_mcmcan.canNodeConfig.can->N[0].NPCR.B.RXSEL = 0x3; -> 0x1;

and i assigned port like below picture(tx:P20.8 , rx:P20.7)

leekings_1-1674987302565.png

leekings_2-1674987397623.png

 

i understand as when i assign CAN port properly, but it doesn't works.

 

can you help me? and can you tell me what i should modify?

 

thank you.

 

 

0 Likes
5 Replies
Di_W
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 250 solutions authored

.

0 Likes
leekings
Level 3
Level 3
50 sign-ins 25 replies posted 25 sign-ins

Thank you for replying.

 

but i can't check image, becuase it is uploaded with very low quality image.

 

can you upload iamge as file? 

 

thank you.

0 Likes
Di_W
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 250 solutions authored

dw_0-1675065954698.pngdw_1-1675065961005.png

 

 

0 Likes
leekings
Level 3
Level 3
50 sign-ins 25 replies posted 25 sign-ins

thank you for replying.

 

i have a question about pin assginment.

 

when i assign CAN tx/rx pin by using pinmapper tool, there was already existing pin settings. like below picture.

(P15.1 / P15.0)

leekings_1-1675506247614.png

 

it defines CAN Module 0 / Node2, so i didnt' delete above assignment.

and i add CAN Module0 / Node 0's assignment by using pinmapper tool. and below code is generated automatically.

leekings_2-1675506268329.png

after generating above code, i didnt' made CAN module configuration, and just modify existing code from (MODULE0/NODE2) 's RXSEL value to MODULE0/NODE0's value.

 

in this condition, TX/RX function is not working properly.  after deleting MODULE0, NODE2's pin assignment from code, it is working normally.

 

here is my question.

Q1. the sample code you show me, set pin directly. but i can also assign Tx/rx pin of CAN module by using pinmapper + set RXSEL value.

when i just assign tx/rx pin by using pinmapper, CAN function doesn't working. after set RXSEL value, it works normally.

can you explain why this happen?

 

Q2. when i just assign CAN MODUE0_NODE0 / MODULE0_NODE2 at simulataneously, CAN function doesn't works well. can you expalin why it work abnormally?

 

thank you.

 

leekings_1-1675506247614.png

 

0 Likes
Di_W
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 250 solutions authored

1) pin mapper is an auxiliary tool, and eventually you need to review the configuration of all pins, because the settings in the final C language file are written to registers

2) First, you could make CAN0 NODE0 working, then you can configure CAN0 NODE2 working, These 2 NODES require 4 pins to configure, and each node requires an RX and TX. In my example above, you can see one node configuration. You can refer to it to configure second node.

0 Likes