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.

TM4C1294NCPDT: Continuously transmitting on CAN.

Part Number: TM4C1294NCPDT


Hi,

       I am trying to transmit the same message on CAN continuously for 5 times like below.

    CANMessageSet(hwAttrs->baseAddr, 2,&sCANMessage,MSG_OBJ_TYPE_TX);

    CANMessageSet(hwAttrs->baseAddr, 2,&sCANMessage,MSG_OBJ_TYPE_TX);

    CANMessageSet(hwAttrs->baseAddr, 2,&sCANMessage,MSG_OBJ_TYPE_TX);

    CANMessageSet(hwAttrs->baseAddr, 2,&sCANMessage,MSG_OBJ_TYPE_TX);

    CANMessageSet(hwAttrs->baseAddr, 2,&sCANMessage,MSG_OBJ_TYPE_TX);

But i am receiving only one message. So how can i transmit the message continuously on CAN??

How do i know that CAN has transmitted current message and ready to transmit next??

Regards,

Digvijay

  • Hi,
    It takes time to transfer the CAN message. If you look at the CAN message format it has 11bit arbitration field, 6bit control field, up to 64bit data field, 15bit CRC field and etc. The fastest bit rate you can get is 1Mbps. At the fastest bit rate it will take mS to send one message. It is much much slower than your CPU writing 5 different CANMessageSet(). You need to insert delay in between them.
  • Hi,

      Thanks for quick reply. Actually right now i am using delays only. But i don't want to use delays. I want to use some intelligence like flag checking or interrupt. They have given example with interrupt in multitx example. But it is not working for me. I am developing library for RTOS similar to other existing library.

    Regards,

    Digvijay

  • Hi
    I am planning on pending semaphore after CANMessageSet() in CAN_write function and posting it in CAN transmission complete interrupt. Will this logic work?? I don't have my board with me for few days so i can not test it on hardware.


    // PARTIAL CODE OF CAN_write
    sCANMessage.ui32MsgID = object->writenode;
    sCANMessage.ui32MsgIDMask = 0;
    sCANMessage.ui32Flags = MSG_OBJ_TX_INT_ENABLE;
    sCANMessage.ui32MsgLen = 8;
    sCANMessage.pui8MsgData = pui8MsgData;
    object->g_bErrFlag = 0;
    CANMessageSet(hwAttrs->baseAddr,
    2, //the object number to configure (1-32).object->writemailbox
    &sCANMessage, //pointer to a structure containing message object settings.
    MSG_OBJ_TYPE_TX);
    Semaphore_pend(Semaphore_handle(&(object->writeSem)), BIOS_WAIT_FOREVER);


    // PARTIAL CODE OF INTERRUPT HANDLER
    else if(ui32Status == 2) //object->writemailbox
    {
    // GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_0, 1);
    CANIntClear(hwAttrs->baseAddr, 2);
    object->g_bErrFlag = 0;
    object->g_bTXFlag = 0;
    Semaphore_post(Semaphore_handle(&(object->writeSem)));
    }

    Regards,
    Digvijay
  • HI,
    In theory, it should work. Give it a try and let us know.
  • Hi,
    I tested it. And works fine without addition of any delays.
    Regards,
    Digvijay