I need some helping advice regarding a simple program.
The code I've written is based on the example '03_TIMER'. I have several messages what should sent out by the device with different timestamps (10ms, 20ms, 100ms, 1000ms and 2000ms). Each timer starts like in the example:
Code: Select all
/***************************************************/
/************ 2000 ms ***************/
/***************************************************/
if (SYSTIME_DIFF (timer2000, timenow) >= 2000000)
{
timer2000 += 2000000;
CANmsg_out.Id = 0x3E9U;
CANmsg_out.Len = 8U;
CANmsg_out.Type = CAN_MSG_STANDARD;
CANmsg_out.Data8[0] = 0x01U;
CANmsg_out.Data8[1] = 0x10U;
CANmsg_out.Data8[2] = 0x00U;
CANmsg_out.Data8[3] = 0x00U;
CANmsg_out.Data8[4] = 0x00U;
CANmsg_out.Data8[5] = 0x00U;
CANmsg_out.Data8[6] = 0x00U;
CANmsg_out.Data8[7] = 0x00U;
CAN_UserWrite(CAN_BUS2, &CANmsg_out);
...
// imagine 5 more instances
I found a workaround and divided the 6 messages into 2 pieces of 3-message packet (timestamp of the 1st packet is 2s, and the other is 1.8s). Right now it is working, and all the messages sent out. So looks like it:
Code: Select all
/***************************************************/
/************ 1800 ms ***************/
/***************************************************/
if (SYSTIME_DIFF (timer1800, timenow) >= 1800000)
{
timer1800 += 1800000;
CANmsg_out.Id = 0x3E9U;
CANmsg_out.Len = 8U;
CANmsg_out.Type = CAN_MSG_STANDARD;
CANmsg_out.Data8[0] = 0x01U;
CANmsg_out.Data8[1] = 0x10U;
CANmsg_out.Data8[2] = 0x00U;
CANmsg_out.Data8[3] = 0x00U;
CANmsg_out.Data8[4] = 0x00U;
CANmsg_out.Data8[5] = 0x00U;
CANmsg_out.Data8[6] = 0x00U;
CANmsg_out.Data8[7] = 0x00U;
CAN_UserWrite(CAN_BUS2, &CANmsg_out);
...
// imagine 2 more instances
}
/***************************************************/
/************ 2000 ms ***************/
/***************************************************/
if (SYSTIME_DIFF (timer2000, timenow) >= 2000000)
{
timer2000 += 2000000;
CANmsg_out.Id = 0x301U;
CANmsg_out.Len = 8U;
CANmsg_out.Type = CAN_MSG_STANDARD;
CANmsg_out.Data8[0] = 0x01U;
CANmsg_out.Data8[1] = 0x10U;
CANmsg_out.Data8[2] = 0x10U;
CANmsg_out.Data8[3] = 0x10U;
CANmsg_out.Data8[4] = 0x02U;
CANmsg_out.Data8[5] = 0x03U;
CANmsg_out.Data8[6] = 0x00U;
CANmsg_out.Data8[7] = 0x00U;
CAN_UserWrite(CAN_BUS2, &CANmsg_out);
...
// imagine 2 more instances
}
Of course, the compiler is error and warning free. I tried the change the optimization level, but it does not influence the behavior.
PEAK PCAN-Router IPEH-002210 07638