This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F280041C: Porting CAN functionality from eCAN to DCAN

Part Number: TMS320F280041C
Other Parts Discussed in Thread: C2000WARE

Dear team,

I'm trying to port code from eCAN to DCAN for the 280041C controller.  This is the below line of code that was written for an eCAN controller. 

//Disable the Mail Box 0

ECanaRegs.CANME.bit.ME0 = 0;


//Enable Acceptance Mask for Mail Box 0
ECanaMboxes.MBOX0.MSGID.bit.AME = 1;

//Enable Mail Box 0
ECanaRegs.CANME.bit.ME0 = 1;


//Enable both Standard and extended frames
ECanaLAMRegs.LAM0.bit.LAMI = 1;


//Set the mask to recevie IDs less than 256, (considered standard identifier)
// Bits 18-28 is for standard identifier. Set bit 18 to 25 to receive ID's less than 256
ECanaLAMRegs.LAM0.all = (ECanaLAMRegs.LAM0.all) | 0x3FC0000;

For example, if I want to change the setting of enabling the mailbox, 

Can I use the below configuration?

//Disabling Mailbox
CanbRegs.CAN_IF1ARB.bit.MsgVal=0;


//Enabling acceptance mask for mailbox 0
CanbRegs.CAN_IF1MCTL.bit.UMask=1;

//Enabling Mailbox
CanbRegs.CAN_IF1ARB.bit.MsgVal=1;

//Enabling both Standard & extended frames
CanbRegs.CAN_IF1ARB.bit.Xtd=0;


//Bits 18-28 is for standard identifier. Set bit 18 to 25 to receive ID's less than 256
CanbRegs.CAN_IF1MSK.all=(CanbRegs.CAN_IF1MSK.all)||0X3FC0000;

Can you please suggest the changes/modifications that should be made while porting the code to DCAN controller(280041C)

Thanks,

Harish K.

  • Harish,

                  First off, you need to use 32-bit R/W in eCAN by using shadow registers. Take a look at the eCAN chapter of the reference guide. And my Application report http://www.ti.com/lit/spra876. You should not access a bit directly like " ECanaRegs.CANME.bit.ME0 = 0;". 

    For the 280041, have you looked at the Driverlib examples in C:\ti\c2000\C2000Ware_3_03_00_00\driverlib\f2837xd\examples\cpu1\can? Also, please download my Application report http://www.ti.com/lit/sprace5. It has many tested examples.

  • For information on how to use bit-fields, please refer to the example in C:\ti\c2000\C2000Ware_3_03_00_00\device_support\f2837xd\examples\cpu1\can_loopback_bitfields\cpu01

  • Dear Hareesh,

    Thanks for the info. The background for this query was that the development has been happening using MATALB/Embedded coder  which uses TI C2000 blockset. And I've use custom block to override the initialization code for the receive block which accepts messages of all ID's which reduces the code overhead by using a single mailbox instead of multiple mailboxes. So, as per the suggestion, I've adapted it to 280041C.

    So, please do let me if I still have to use the shadow register approach. In case if I don't, can you please verify the configuration of registers that I shared earlier.

    Thanks,

    Harish K. 

  • Harish,

              Not sure if your latest query is about the eCAN or the DCAN. If it is the eCAN, using shadow registers (to enable 32-bit R/W) is a must. This is a device requirement and is independent of whether you use MATLAB/Embedded coder or not. 

    If it is the DCAN, please take a look at the bit-field example in C2000Ware.

  • Dear Hareesh,

    Yes. My query is about DCAN only. I'm looking into the example that you've specified.  I would like to add some specific details here. The current CAN receive block in the embedded coder doesn't support the access for multiple messages via a single mailbox. So, I've to rewrite the already.

    The 'Init' function is only responsible for checking if only one message ID is configured for each mailbox. If more than 1 message ID is configured for the same mailbox, then the validation fails and it will return an error. And this call back function is only for validating the mailbox. So, I'll be removing the validation function which has been written for the existing receive block & replacing with the one with shadow register approach. 

    I did look into the bit field register example.  I believe it didn't discuss about the acceptance filtering. Can you suggest an example where acceptance filer using DCAN has been used.

    Thanks,

    Harish K.

     

  • Harish,

                  I regret I am not familiar with Embedded Coder. 

    We are encouraging customers to move away from bit-fields and use Driverlib. This is the reason you don’t see bit-field examples for 280041C, the device you are using. 

    Can you suggest an example where acceptance filer using DCAN has been used?

    Please take a look at the Mask example in SPRACE5. 

    Note that the behavior of the mask bits is opposite between DCAN & eCAN.