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/TM4C1294NCPDT: CAN bus communication issue with SN65HV CAN bus transiever

Part Number: TM4C1294NCPDT

Tool/software: Code Composer Studio

Dear All,

We have custom developed board with TM4C1294NCPDT MCU and SN65HV CAN Bus Transiever. It seems the CAN Message is continuously sending CAN messages when starts the CAN Bus communication for the first time, sometimes every 500us/ 1.5ms.  What could be the reason for this?  Here the Node is acknowledging the data, Hence not a bad node issue.

Could See the TXOK bit of CTL_STS is always high and the message is Acknowledged by the second Node(PFA images). Even being able to get the correct data in the second node.

PF Below CAN Init Code :

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); // enable CAN1 GPIO peripheral
SysCtlPeripheralEnable(SYSCTL_PERIPH_CAN1);
GPIOPinConfigure(GPIO_PB0_CAN1RX);
GPIOPinConfigure(GPIO_PB1_CAN1TX);
GPIOPinTypeCAN(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);

CANInit(CAN1_BASE);
CANBitRateSet(CAN1_BASE, sysClock, 100000);
// CANIntRegister(CAN1_BASE, CANIntHandler); // use dynamic vector table allocation
CANIntEnable(CAN1_BASE, CAN_INT_MASTER | CAN_INT_ERROR | CAN_INT_STATUS);
IntEnable(INT_CAN1);
CANEnable(CAN1_BASE);

TxMessage.ui32MsgID = 1;
TxMessage.ui32MsgIDMask = 0;
TxMessage.ui32Flags = MSG_OBJ_TX_INT_ENABLE;
TxMessage.ui32MsgLen = 8;
TxMessage.pui8MsgData = TData_Ptr;

Can Send Data  :

for (j=(4*seq);j<(4*(seq+1));j++)
{
TData_Ptr[j]=can_node_data.D[node][j];

}
IntMasterDisable();
CANMessageSet(CAN1_BASE, 1, &TxMessage, MSG_OBJ_TYPE_TX); // send as msg object 1
delay_ms(10);
IntMasterEnable();

  • akhil joy said:
    the CAN Message is continuously sending CAN messages

    followed by your  "CanSendData"

    akhil joy said:
    for (j=(4*seq);  j<(4*(seq+1));  j++)

    Might such a "complex expression" first "invite" - and then "cause & continue" -  your  (undesired) continuous CAN Sending?

    You have noted - & reported - such,  "Continuous Sending" -  thus does not your "For Loop"  -  very  much RISE w/in your "suspect list"  -  and deserve increased,  even (some)  scrutiny?

    Code you've provided - nowhere (that I can find) provides initialization - of (either) "j" or "seq."      Should both (j, seq) - start from zero - and monotonically increase - I don't believe that your  code  can "EVER ESCAPE"  that loop - thus the "Continuous Sending" - registers as totally,  "expected!"

    It is always wise - when attempting new code - to follow "KISS" - and employ  extremely clear, basic, (likely) "hard-coded"  test values...

    You may (both) test & confirm my finding - via the quick/eased  "Replacement of that  "Suspect For Loop" - with a,  "One and Only "One Time" call to your,  (enhanced,  "For Loop FREE"),  "Can Send Data()"  function...

    As things stand now - does not the possibility exist - that your, "Desired CAN code analysis - is being  "Held Hostage" - by a "Failed code mechanism"  - no way related - to CAN?

  • Hi,

    Is CAN SN65HV set in standby mode? standby (pin 8) 10k++ into GPIO port control? That make HD65 wait listen for RXD data on bus prior to send any TXD out.

  • Hi cb1_mobile (1830783)  thanks for Suggestions,  the Code here attached is part of application code where CAN message is sending.

    j and Seq is properly initialized and will never go in the loop.  this verified as per your suggestion (For loop is removed and tested without success).

  • HI this one is having slope control on 8th pin , and is connected with 10K + resistor.
  • Another Observation is when i commented out the TX int Enable flasgs everything works as expected.

    // TxMessage.ui32Flags = MSG_OBJ_TX_INT_ENABLE;

    Anyidea what could went wrong ?
  • And is the GPIO pin 8 set high, SN65 in standby mode? Recall datasheet states pin 8 high (stdby mode) keeps TXD pin quiet from RXD bus noise causing false TDX events. Seemingly TXD function must also set pin 8 low prior to sending data.
  • Please note - your, "Works as expected" provides little "clear description" - and proves NOT compelling.
    What were those "expectations" - minus that statement - helpers must "guess" - which is not famed as a (sound) diagnostic process...

    Pardon - but I "cannot parse" (glean understanding) from your statement, "j and Seq is properly initialized and will never go in the loop."      What does "never go - in the loop" - really mean?    And - what were those "initialized values?"

    Would it not prove best for you to,  "note both "j and seq's" initial values - and then,  "Chart their progression - while "captive" w/in that For-Loop?"     (when we did such - w/both "starting from "0" - the loop could NOT be escaped!)    In addition - you must inform those here - "If and how" - either "j or seq" -is subject to modification - elsewhere!    (Indeed - details...details...)

  • Please Note : " (For loop is removed and tested without success)"

    Work as expected , ie CAN bus is not trasnsmitting continous messages but Sending only when send function is called.

    its something related to TX INT Flag , When i enable this flag, message is sending continously. and "TX OBJ INT" log is continously printed in the console.

    CAN INT HANDLER :

    uint32_t status = CANIntStatus(CAN1_BASE/*cport.canBase*/, CAN_INT_STS_CAUSE);
    if(status == CAN_INT_INTID_STATUS)
    {

    status = CANStatusGet(CAN1_BASE, CAN_STS_CONTROL); // read back error bits, do something with them?

    errFlag = 1;
    }
    else if(status == 1)
    {
    CANIntClear(CAN1_BASE, 1);
    errFlag = 0;
    MsgObjSent = 1;
    console("TX OBJ INT")
    }
  • Pin 8 is pull down to Gnd with 10K , Now tried by pulling directly to Gnd without success , i will tap the channel and see if there is any noise in the channels
  • Did you resolve this problem?
  • No , We are still working on this to identify the issue..

  • I suspect that the problem is in your CAN interrupt service routine. Do you mind showing that code?
  • I have not heard back from you. Is the problem resolved?