Skip to main content
Visitor II
January 25, 2024
Solved

How to send can messages with different cycles in spc5 studio?(spc58ec-disp)

  • January 25, 2024
  • 1 reply
  • 1187 views

hello~

I am using the spc58ec disp chip and want to continuously send CAN messages of different cycles.

Here is the code what i wrote:

////

void send_10ms(){

    uint32_t rv;

    CANTxFrame msg_10ms;

    msh_10ms.ID = 0x11U;

    msh_10ms.DLC = 8U;

    msh_10ms.data32[0] = 0x1234U;

    rv = can_lld_transmit(&CAND2, 0, &msg_10ms);

    osalThreadDelayMilliseconds(10);

}

// and also have a similer fcuntion which send 100ms can message

////

I want them to send in different cycles.

The above can messages can only be sent in 100ms, how should they be modified?

Thank you~

This topic has been closed for replies.
Best answer by Max VIZZINI

Hi,

Every 10 messages a 10ms will clash in the same cycle of the 100ms message.

Try messages at 11ms and 100ms that should avoid they activate at the same cycle.

You can set two PITs (timers) to be woken up at the right time with an interrupt at the right moment.

Keep the interrupt handling routines short for best performance, e.g. change a state variable to record that the timer has expired.

For this and a lot of other common cases, you can access the examples under the AutoDevKit ecosystem

www.st.com/autodevkitsw 

Best Regards,

AutoDevKit Team

 

1 reply

Max VIZZINI
Max VIZZINIBest answer
Technical Moderator
January 26, 2024

Hi,

Every 10 messages a 10ms will clash in the same cycle of the 100ms message.

Try messages at 11ms and 100ms that should avoid they activate at the same cycle.

You can set two PITs (timers) to be woken up at the right time with an interrupt at the right moment.

Keep the interrupt handling routines short for best performance, e.g. change a state variable to record that the timer has expired.

For this and a lot of other common cases, you can access the examples under the AutoDevKit ecosystem

www.st.com/autodevkitsw 

Best Regards,

AutoDevKit Team