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/LAUNCHXL2-570LC43: How to instert delay between two CAN bus signals.

Part Number: LAUNCHXL2-570LC43
Other Parts Discussed in Thread: HALCOGEN

Tool/software: Code Composer Studio

Hello TI,

Can anyone help me how to give delay of one second between two CAN signals for the Hercules TMS570LC43x Launchpad.

While using Halcogen there is no option to give cycle time, and while using interrupts also it is not working.

If anybody can give me a piece of code using interrupts to get CAN signals separated by one second, then it will be great. 

  • Hello RASHMI,

    There is no HW mechanism to insert delay between each transfer. You can add delay using SW:

    1. using RTI counter

    2. transfer a empty CAN frame (data length = 0)

  • Hey Wang thanks for your reply. Can you please give me a piece of code how to write empty CAN signals or giving RTI interrupt, otherwise can you please suggest me any pages where I can get an idea of it.
  • This is an example to generate delay using RTI timer:

    #define TIMER_LOAD_VAL 0xffffffff
    #define READ_TIMER (0xFFFFFFFF - *(volatile ulong *)(0xFFFFFC00 + 0x10))
    #define CFG_HZ ( your vclk in Hz ) /*for example 80000000 (80MHz),*/

    //usec is micro-second, tmo is clock cycle
    void delay (unsigned int usec)
    {
         unsigned int tmo, tmp;
         if(usec >= 1000){
             tmo = usec / 1000;
             tmo *= CFG_HZ;
             tmo /= 1000;
         }else{
             tmo = usec * CFG_HZ;
             tmo /= (1000*1000);
         }
         tmp = get_timer_masked();      /* get current timestamp */
         if( (tmo + tmp + 1) < tmp ){
            lastdec = READ_TIMER; 
            timestamp = 0;
          }
         else
            tmo += tmp;
         while (get_timer_masked () < tmo)   /* loop till event */
    }

    ulong get_timer_masked (void)
    {
         unsigned int now = READ_TIMER;    /* current tick value */

         if (lastdec >= now) {
            /* normal mode */
            timestamp += lastdec - now;
         } else {
            timestamp += lastdec + TIMER_LOAD_VAL - now;
         }
            lastdec = now;
            return timestamp;
    }