TC27x MultiCAN

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

cross mob
User17091
Level 1
Level 1
Hi,

I'm preparing CAN communication for AURIX™ TC27x D-Step based on the example from User’s Manual V2.2 2014-12
.
The code from chapter 22.5 works perfectly with loopback mode.

(8) CAN_NPCR0 = (1 << 8); // LBM=1
(9) CAN_NBTR0 = 0x3EC9; //set bit segments
...
(11) CAN_NPCR1 = (1 << 8); // LBM=1
(12) CAN_NBTR1 = 0x3EC9; //set bit segments


My goal is to communicate with other CAN device via TXDCAN0/RXDCAN0A

CAN_NPCR0.U = 0x001; // set NPCRx.RXSEL 001 to select Port 20.8 for TXDCAN0 and Port 20.7 for RXDCAN0A
CAN_NPCR1.U = 0x001;

unfortunately it doesn't work after selecting the port and I'm not sure if the code or wiring or bitrate is wrong.

Thanks in advance.

Similar thread:
https://www.infineonforums.com/threads/3030-Problem-with-using-CAN-Module-on-TC275
0 Likes
5 Replies
MoD
Employee
Employee
50 likes received 500 replies posted 100 solutions authored
Hi,
you must configure the P20.8 as output of TXDCAN0 (P20.IOCR8) and P20.7 as input for RXDCAN0A (P20.IOCR4).
Addtional the PDR Register for P20.8 should be set to the needed output strength (depends on needed CAN speed).
0 Likes
User17091
Level 1
Level 1
Thank you for quick response.

Before updating the code I've checked related registers values in UDE after calling iLLD function :


CAN0_Init(125000);


PC8 = 0x15 in P20_IOCR8 looks ok however I do not see P20_PDR.B.PD1 = 0 (speed grade 1)

Are these settings correct for Port 20.8/TXDCAN0 and Port 20.7/RXDCAN0A with 125000 bitrate ?

Thanks

3599.attach
0 Likes
MoD
Employee
Employee
50 likes received 500 replies posted 100 solutions authored
Config seems be good. Check the output P20.8 when you send anything on this node. Because you set also node 1 you will use there P14.0/P14.1. If the IO config for P14.0/P14.1 is also correct?
You are sure that you have a transceiver on this two pairs P20.7/P20.8 and P14.0/P14.1 and they are connected togheter?
0 Likes
User17091
Level 1
Level 1
You are right - the sample from chaper 22.5 uses node0 for TX and node1 for RX (via loopback).


(14) CAN_PANCTR = (1 << 24)|(0 << 16)| 2; // MO 0 to list 1
(16) CAN_PANCTR = (2 << 24)|(1 << 16)| 2; // MO 1 to list 2


As I need only one node I updated the code like below and TX/RX works fine via TXDCAN0/RXDCAN0A


CAN_PANCTR.U = (1 << 24)|(0 << 16)| 2; // MO 0 to list 1
CAN_PANCTR.U = (1 << 24)|(1 << 16)| 2; // MO 1 to list 1


Thank you for support.
0 Likes
User20829
Level 1
Level 1
Hi,

i also try to get the CAN running on an TC29x.
I implemented the example from the data sheet. The loop mode working fine but i can't transmit messages over the can ports.
I use the evaluation board with 20MHz oscillator. I use the oscillator for the clock source of the MultiCAN.

I can measure signals on the output of the CAN-Tranceiver but the baud rate is completely wrong.
The first bit (SOF) is mostly 18x bigger than expected. I send a standard frame with CAN-ID 0x7FF to get a dominant Bit for the SOF.




	ScuEndinitClear(); /* reset ENDINIT to get access to ENDINIT protected registers */

portCAN0->IOCR0.B.PC2 = 0x02; /* Pullup IN P34_2 CAN_Rx*/
portCAN0->IOCR0.B.PC1 = 0x14; /* Alternate output function 4 (CAN_TX) OUT P34_1 CAN_Tx*/

module->CLC.U = 0x000; // disable module control
dummy = module->CLC.U; //read to check the made changes
module->FDR.U = (1 << 14) | 0x3FF; //DM=1,STEP=1023
module->MCR.U = 0x2; // CLKSEL: 1=PLL , 2=Oscillator Clock

ScuEndinitSet(); // lock ENDINIT reg


//Init CAN nodes 0(TX) and 1(RX):
CANhwNode0->CR.U = (1 << 6)| 1; // CCE=1,INIT=1
//CANhwNode0->PCR.U = (1 << 8); // LBM=1
CANhwNode0->BTR.U = 0x3e07;//127kBit with 20MHz
CANhwNode1->CR.U = (1 << 6)| 1; // CCE=1,INIT=1
//CANhwNode1->PCR.U = (1 << 8); // LBM=1
CANhwNode1->PCR.B.RXSEL = 0x3; // select P34_2 CAN_Rx
CANhwNode1->BTR.U = 0x3e07; //127kBit with 20MHz

//Allocate message objects to CAN nodes:
while(module->PANCTR.U & (0x00000100 | 0x00000200)); // busy?
module->PANCTR.U = (1 << 24)|(0 << 16)| 2; // MO 0 to list 1
while(module->PANCTR.U & (0x00000100 | 0x00000200)); // busy?
module->PANCTR.U = (2 << 24)|(1 << 16)| 2; // MO 1 to list 2
//module->PANCTR.U = (1 << 24)|(1 << 16)| 2; // MO 1 to list 1
//Init MO_0 (list 1, node 0)
hwObj0->CTR.U = (1<<27)|(1<<26)|(1<<25)|(1<<21); // set to Tx
hwObj0->FCR.U = (8 << 24); // DLC=8
hwObj0->AR.U = (1 << 30)|(0x7FF << 18); // PRI=01,ID=0xFF
//Init MO_1 (list 2, node 1)
hwObj1->CTR.U = (1 << 23)|(1 << 21); // set to Rx
hwObj1->FCR.U = (1 << 16); // RXIE=1
hwObj1->AR.U = (1 << 30)|(0x7FF << 18); // PRI=01, ID=0xFF
hwObj1->IPR.U = 0x1; // RXINP=1 -> select INT_O1
//TODO SRC_CANINT1 = (1 << 10) | CAN_SRN1INT; // enable INT_01
//TODO interruptHandlerInstall (CAN_SRN1INT, & CAN1_Rx_irq);
// Load Data, Start CAN nodes
hwObj0->DATAL.U = 0x0D0D0D0D; // load data, lower 4 Bytes
hwObj0->DATAH.U = 0x0E0E0E0E; // load data, higher 4 Bytes
CANhwNode0->CR.U &= ~((1<<6)| 1); // reset CCE and INIT
CANhwNode1->CR.U &= ~((1<<6)| 1); // reset CCE and INIT
// set transmit request to send message
hwObj0->CTR.U = (1<<24)|(1<<19)|(1<<6);//TXRQ=1,NEWDAT=1
while((hwObj1->STAT.B.NEWDAT) != 1); //check if Rx


Maybe someone see some wrong configuration?

thx
0 Likes