CCS/TMS320F28075: CAN Initial Setup Problem

Prodigy 20 points

Replies: 3

Views: 57

Part Number: TMS320F28075

Tool/software: Code Composer Studio

Hi Experts:

I have some problem about CAN initial. I want to use IF2 to receive CAN data and receive interrupt. But when I run code. CAN cannot Interrupt. Baud Rate set as 1Mbps.

Is there anything I forgot to set?

Furthermore. I don't know how to use 28075 mailbox. I used 28069 before. But there are some different. Is there anyone have source code can reference?

These is my source code:

void cana_init(void)
//Init bit set
CanaRegs.CAN_CTL.bit.Init = 1;

//Configure CAN RX and TX pins
CanaRegs.CAN_IF1MCTL.bit.DLC = 9;//Data Length
CanaRegs.CAN_IF1MSK.bit.Msk = 0x40000;//address
CanaRegs.CAN_IF1CMD.bit.DIR = 1;

CanaRegs.CAN_IF2MCTL.bit.DLC = 9;
CanaRegs.CAN_IF2MCTL.bit.RxIE = 1;//Receive Interrupt Enable
CanaRegs.CAN_IF2MSK.bit.Msk = 0x80000;
CanaRegs.CAN_IF2CMD.bit.DIR = 0;

//Configure Bit Timing
CanaRegs.CAN_CTL.bit.CCE = 1;// set CCE to access timing
CanaRegs.CAN_BTR.bit.BRPE = 7;//tq=(BRPE/BRP)/CAN_CLK
CanaRegs.CAN_BTR.bit.BRP = 1;
CanaRegs.CAN_BTR.bit.TSEG2 = 2;
CanaRegs.CAN_BTR.bit.TSEG1 = 10;

CanaRegs.CAN_CTL.bit.Init = 0;
CanaRegs.CAN_CTL.bit.CCE = 0;

CanaRegs.CAN_CTL.bit.IE0 = 0;
CanaRegs.CAN_CTL.bit.IE1 = 1;

3 Replies

  • Hi,

    Have you ever considered using the driverlib examples that were released in C2000Ware.  The examples and routines cover exactly what you are trying to replicate in your code and sets up the bit timing for you given the system clock speed and CAN speed.  In the functions, IF2 is used for receive.  For the receive interrupt, are you planning to use ISR to read out the messages as they are received?  If so then you need to configure PIE and CAN_GLB_INT_EN.

    As for accessing the mailboxes in F28075, you have to do everything through the IF registers as you cannot read/write to those locations directly.  The driverlib function CAN_transferMessage() does this for you.



  • In reply to Joseph Casuga:

    Hi, Joseph

    I have use example. But when I use example. I get wrong baud rate. I only change clock source as internal clock 2. And get SYSCLK is 120MHz. And example baud rate is 500kbps. But when I use oscillator scope. I found that every bits use 20 micro seconds.  Furthermore, the register I set is BRR= 15 BREP=0 TSEG1=10 TSEG2=2. And SYSCLK=120MHz. As a result. Baud Rate=120M/(16+(10+2+3)). Is there anything I miss?


  • In reply to Lin Yuhsuan1:

    Hi Lin,

    The driverlib examples assume SYSCLK  is 200MHz.  You would need to change your clock settings to get to 200MHz SYSCLK, even if you are using the internal oscillator.