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.

CCS/TMS320F28379D: CAN register accessing errors

Part Number: TMS320F28379D
Other Parts Discussed in Thread: C2000WARE

Tool/software: Code Composer Studio

Hi,

I have problem regarding CAN register accessing through structures or byte peripheral access 8bit/16bit/32bit as mentioned in reference manual. Regardless of anything when i was setting one bit from software it was setting from another bit in CAN register when i am checking in watch window. Even the examples i have tried, but it was executing the same as well. Can anyone resolve the issue? or provide me a better example source code to CAN driver.

  • Hi Rajesh,

    Can you be more clear on what register you are trying to access, what api you are using to access the register and how you are trying to set a bit of that register.

    This is an example of setting a bit of IF cmd register. 

    HWREG_BP(base + CAN_O_IF1CMD) |= (uint32_t)CAN_IF1CMD_CONTROL ;

    Here im setting the IF1 cmd control bit of the register (note the type cast of the defined value) by keeping the previous state of the register as it is by putting an OR.

    Thanks

    Yashwant

  • Hi Yashwant,

    Thanks for you, i am using F2837xD_can.h header file, and my problem is when i am setting Init Bit using CanbRegs It wasn't set as i have seen in debug process. and when try to set CCE bit it was setting other reserved bits and all. and also when i try to load the value of 0xAABBCCDD in the CAN_BTR register i observe that first 5bits position that is BRP is setting to CC value remaining values remains as 0 in the register.

    Then as mentioned in the Technical Reference manual i hv tried with HWREG(Base+offset) even then the value is loading as same explained above

    What i am using now :

    CanbRegs.CAN_CTL.bit.Init  = 1;
    CanbRegs.CAN_CTL.bit.CCE   = 1;
    CanbRegs.CAN_BTR.all = 0x00003476;

    What i am observed now in watch

    CanbRegs.CAN_BTR.BRP = 52;

    CanbRegs.CAN_BTR.SJW = 0;

    CanbRegs.CAN_BTR.TSEG1 = 0;

    CanbRegs.CAN_BTR.TSEG2 = 0;

    CanbRegs.CAN_BTR.Rsrvd = 0;

    CanbRegs.CAN_BTR.BRPE = 0;

    Can u plz sort out this problem and provide me a solution.

    Thanks,

    Rajesh.

  • Hi Rajesh,

    Which version of C2000Ware are you using. You can find the latest version here https://www.ti.com/tool/C2000WARE .

    You can find CAN examples in

    C2000Ware_3_03_00_00\driverlib\f2837xd\examples\cpu1\can

    In ex1 you can see how the bit rate is set using CAN_setBitRate() function.

    You can refer C2000Ware_3_03_00_00\device_support\f2837xd\docs\DCAN_CANBTR_values.xlsx file allowed bit timing values for desired brps.

    To check the register value you can open memory browser view and type the (base + offset) value of CAN_BTR register in the input.

    Thanks,

    Yashwant

  • Present i am going with V3.00.00.00. and with that given 4 examples i got same results as explained above, so please provide me one source code example file to configure the driver

  • Rajesh,

    Are the examples working as expected? In can loopback example is the g_ulMsgCount value incrementing? Can you check the registers in registers view.

    After adding the line CanbRegs.CAN_BTR.all = 0x00003476;

    We can correctly see the value being written to the register in register view.

    Regards,

    Yashwant

  • Hi Rajesh,

    This could be an issue with the Expressions window. Can you use the Registers View to check the register value?

    Regards,

    Veena

  • Hi Yashwant and Veena,

    Thanks for the both of you, these solutions made me clear about the bitrate setting and other initialiazations too.

    Thanks & regards,

    N.Rajesh Sai