Problem with using CAN Module on TC275

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

cross mob
Not applicable
Hello?

I'm trying to use external CAN Module with port (I mean no loop-back mode)


void CAN_vInit(void)
{


EE_tc_endint_disable(); //disable ENDINIT lock to access system register (Erika Enterprise API)
CAN_CLC.U = 0x00000000; //enable module control bit 0 means switch on
while((CAN_CLC.U & 0x00000002) == 2); //wait until module is enabled
CAN_KRST0.U = 1;
CAN_KRST1.U = 1;
while(CAN_KRST0.U != 0x2);
CAN_KRSTCLR.U = 1;
CAN_OCS.U = 0x00000001;
CAN_FDR.U = 0x43FF; //load fractional divider register -> it is diffrent from tc1797 start here!!!
EE_tc_endint_enable(); //enable ENDINIT lock to protect system register (Erika Enterprise API)


CAN_MCR.U = 0x1; //set clk source. it is only possibly modified when NCR0.CCE bit is set.

CAN_NCR0.U = (1 << 6) | 1; //initialization and configuration mode for CAN node 0
CAN_NIPR0.U = 0x00000000; // load node 0 interrupt pointer register
CAN_NECNT0.U = 0x00600000;
CAN_NPCR0.U = 0x00000000; //set NPCRx.RXSEL 001 to select Port 20.8 for TXDCAN0 and Port 20.7 for RXDCAN0A



P02_IOCR0.U = 0x00001000; //P02.1 RXCAN0



P02_IOCR4.U = 0x00008800; //P02.5 TXCAN0



CAN_NBTR0.U = 0x00003449; //set baud rate for 1Mbit/s

//Allocate Message objects to CAN nodes
while(CAN_PANCTR.U & (0x00000100 | 0x00000200));
CAN_PANCTR.U = 0x01000002;
while (CAN_PANCTR.B.BUSY);

//Init MO 0
//CAN_MOCTR0.U = 0x0EA80000;
//CAN_MOCTR0.U = (CAN_MOCTR0.U & ~0xFFFFFFFF) | ( 1 << 27) | ( 1 << 26 ) | ( 1 << 25) | ( 1 << 21);
CAN_MOCTR0.U = 0x0EA80000 | ( 1 << 21);
CAN_MOFCR0.U = (8 << 24);

//CAN_MOAR0.U = (1 << 30) | (0xFF << 18);
CAN_MOAMR0.U = 0x3FFFFFFF; //load MO0 acceptance mask register
//CAN_MOAR0.U = 0xDFF00000; // load MO0 arbitration register
CAN_MOAR0.U = 0xA0000000;
//Load Data, Start CAN nodes
CAN_MODATAL0.U = 0x00000000;
CAN_MODATAH0.U = 0xFF000000;




CAN_NCR0.U &= ~((1<<6) | 1); //reset INIT and CCE to start the CAN Nodes

while(1)
CAN_MOCTR0.U = 0x07000000; // transmit


} // End of function CAN_vInit

This is my code. I use Erika Enterprise for building the project.
I think that there is a problem with ports but I don''t know why it doesn't work.
Please let me know how I can get through this problem.
0 Likes
1 Reply
MoD
Employee
Employee
50 likes received 500 replies posted 100 solutions authored
Hello,
with reset values for pad driver mode the ports are set to speed grade 4. This is the slowest setting. Change the setting for the used pin to speed grade 1 (P02_PDR.B.PD5 = 0; and P02_PDR.B.PD1 = 0).
0 Likes