cancel
Showing results for 
Search instead for 
Did you mean: 

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

donggenhan
Associate

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~

1 ACCEPTED SOLUTION

Accepted Solutions
Max VIZZINI
ST Employee

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

 

View solution in original post

1 REPLY 1
Max VIZZINI
ST Employee

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