I want to increase the CyclicTime of a routed message from 100ms to 200ms. I thought it wil be simple, using your "Timer"-Example, but I got stuck with it. Maybe I think too short.
For testing, I modified your Example:
Code: Select all
// process messages from CAN2
if ( CAN_UserRead ( CAN_BUS2, &RxMsg) != 0)
{
// message received from CAN2
LED_toggleCAN2 ^= 1;
if ( LED_toggleCAN2)
{
HW_SetLED ( HW_LED_CAN2, HW_LED_ORANGE);
}
else
{
HW_SetLED ( HW_LED_CAN2, HW_LED_GREEN);
}
// copy message
TxMsg.Id = RxMsg.Id;
TxMsg.Type = RxMsg.Type;
TxMsg.Len = RxMsg.Len;
TxMsg.Data32[0] = RxMsg.Data32[0];
TxMsg.Data32[1] = RxMsg.Data32[1];
// send
//CAN_UserWrite ( CAN_BUS1, &TxMsg);
}
// send a message every 50 millis
timenow = SYSTIME_NOW;
if ( SYSTIME_DIFF ( LastCycleMsg, timenow) >= 200000)
{
// adjust last time of message by 50 millis
LastCycleMsg += 200000;
// increment a simple counter
//CycleMsg.Data16[0] += 1;
// send
//CAN_UserWrite ( CAN_BUS1, &CycleMsg);
CAN_UserWrite ( CAN_BUS1, &TxMsg);
Where went I wrong?
Thx & Best regards
Mirko