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.

Cyclic Transmission Of CAN Message

Hie, 

I am using the TMS57031 HDK, and I want to Transmit a Can message Cyclically Depending on the Value that is Specified. 

For Example If i have 500ms for Message1 it has to be transmitted every 500ms

 Message2 with preiod 1ms then transmit it every 1 ms after a function to send them is called. 

I Tried using the RTI compare Counter approach but the Problem is that there are not many counters available. for all the messages to be transmitted. 

Could any one please give me another approach to transmit message Cyclically. It is really very important...

Cheers,

Ishan  

  • Hi Ishan,

    This is pretty basic stuff. I don't know whether you're using an operating system, but if not task scheduling in a real-time environment would be performed by a scheduler you need to write. This would normally be driven off the RTI type module which would generate a 1ms interrupt task from which a cascade of other slow tasks (for example 5ms, 10ms, 100ms, 500ms) would be called, by use of incrementing counters to count the milliseconds. So the 1ms task would schedule a 10ms task by counter to 10. The 10ms task would schedule a 100ms task by counter to 100 etc.

    Hope this helps.

    Cheers, Tony.

  • Hello Ishan,

    I have forwarded your post to one of our experts.  They will respond back soon.

  • Ishan,

    You can do the following for what you want to achieve.

    " For Example If i have 500ms for Message1 it has to be transmitted every 500ms.  Message2 with preiod 1ms then transmit it every 1 ms after a function to send them is called."

    If you do not use  an OS, set a RTI interrupt every 500ms. Send message 1 in ISR. In the ISR, maintain software counter (increment a variable) as follows. count should be a global variable.

      counter++;

    if(counter &0x2) send_message_2();

    Thanks and regards,

    Zhaohong

  • Hi Zhaohong,

    You have misread Ishan's requirement. Your solution will transmit message every 500ms and 1000ms.

    Ishan needs a 1ms and 500ms message which is why I described a 1ms interrupt with 500ms scheduled task therein.

    Cheers, Tony.

  • Hey, Thanks Zhaohong and Tony for replying so soon, 

    I have already implemented what Tony told, but the problem with me is, 

    I need a function which when called will keep on transmitting the message at an interval of the mentioned cycle time, and that cycle time could be anything, and different for as many messages as possible. 

    I want something where I can Just take the value of the Period from the user. 

    It would be really appreciated if I get any feeds on this, as it is a very high priority project. 

    Also, Zhaohong if you could give me with any example code, that implements a full CAN communication Stack so it gives me an idea for what I am looking for.

    Cheers, 

    Ishan 

  • Hi Ishan,

    I would have a table of timers, one for each of your message types which would be initialised or reset whenever you need by a calling function. This value would be the period in milliseconds that you require. Then, within your 1ms interrupt, decrement this count, and when it is zero send the CAN message. Then reset the count back to its start value (you would obviously have to store this in a talbe againt the message type as well). ready for the next countdown.

    Cheers,

    Tony.