two input (Chan1 and Chan2) channels with 132 Messages repeated every 50 ms (total of 20 x 132 Messages per second)
The load of Chan1 and Chan1 is around 85% per channel. All with 500kb/s CAN normal. no extended, no FD.
I want to extract half of the messages from each channel and combine in a third channel
The output load on Chan3 is around 65% with 138 messages every 50 ms.
It looks like the program is not fast enough to transport all channels from 1+2 to channel 3 (see code below).
The effect is that some signals have 100, 150, 250 millisec time difference instead of around 50 millisec. So some signals are just DROPPED.
My question: Is there a limitation on how much the processor can do?
Regards
C.
Code: Select all
int main ( void)
{
HW_Init();
CAN_UserInit();
SYSTIME_Init();
HW_SetLED ( HW_LED_CAN1, HW_LED_OFF);
HW_SetLED ( HW_LED_CAN2, HW_LED_OFF);
HW_SetLED ( HW_LED_CAN3, HW_LED_OFF);
HW_SetLED ( HW_LED_CAN4, HW_LED_OFF);
main_greeting();
u32_t FakeRightScanIndex=0,FakeLeftScanIndex=0;
//radar_initialize();
u32_t timenow,timeRight=0,timeLeft=0;
timenow = SYSTIME_NOW; //u32_t
while ( 1)
{
CANMsg_t RxMsg, TxMsg;
// process messages from CAN1
if ( CAN_UserRead ( CAN_BUS1, &RxMsg) != 0)
{
if ( RxMsg.Id == 0x7E7 && RxMsg.Type == CAN_MSG_STANDARD)
{
main_check_flashmode ( &RxMsg);
} // this block must stay in CAN_BUS1
if (RxMsg.Id >= 0x400 && RxMsg.Id <= 0x43F) //
{
RxMsg.Id = RxMsg.Id + 0x200; // from 300 to 600
CAN_UserWrite(CAN_BUS3, &RxMsg);
if (RxMsg.Id == 0x63F )//
{
RightDet64 = 1;
LED_toggleCAN1 ^= 1;
if (LED_toggleCAN1)
{
HW_SetLED(HW_LED_CAN1, HW_LED_OFF);
}
else
{
HW_SetLED(HW_LED_CAN1, HW_LED_GREEN);
}
}
}
if (RxMsg.Id == 0x1C0 && RightDet64) // send status
{
RightDet64 = 0;
FakeRightScanIndex++;
RxMsg.Id = 0x4E0; //
CAN_UserWrite(CAN_BUS3, &RxMsg);
RxMsg.Id = 0x4E1; //
CAN_UserWrite(CAN_BUS3, &RxMsg);
RxMsg.Data32[0]= 0x00000822;
RxMsg.Data32[1]= 0x6600F026; //third
RxMsg.Id = 0x4E2; //
CAN_UserWrite(CAN_BUS3, &RxMsg);
RxMsg.Id = 0x4E3; //
CAN_UserWrite(CAN_BUS3, &RxMsg);
RxMsg.Id = 0x4E4; //
CAN_UserWrite(CAN_BUS3, &RxMsg);
} // Detections from CAN1 send to CAN3 end
} // -------------------- end CAN1 --------------------------
if ( CAN_UserRead ( CAN_BUS2, &RxMsg) != 0)
{
// Detections from CAN2 send to CAN3
if (RxMsg.Id >= 0x300 && RxMsg.Id <= 0x33F) //
{
RxMsg.Id = RxMsg.Id + 0x200; // from 300 to 500 Left side
CAN_UserWrite(CAN_BUS3, &RxMsg);
if (RxMsg.Id == 0x53F )//
{
LeftDet64 = 1;
LED_toggleCAN2 ^= 1;
if (LED_toggleCAN2)
{
HW_SetLED(HW_LED_CAN2, HW_LED_OFF);
}
else
{
HW_SetLED(HW_LED_CAN2, HW_LED_GREEN);
}
}
}
if (RxMsg.Id == 0x180 && LeftDet64) // send status
{
LeftDet64 = 0;
RxMsg.Id = 0x4D0; //
CAN_UserWrite(CAN_BUS3, &RxMsg);
RxMsg.Id = 0x4D1; //
CAN_UserWrite(CAN_BUS3, &RxMsg);
RxMsg.Data32[0]= 0x00000822;
RxMsg.Data32[1]= 0x6600F026; //third
RxMsg.Id = 0x4D2; //
CAN_UserWrite(CAN_BUS3, &RxMsg);
RxMsg.Id = 0x4D3; //
CAN_UserWrite(CAN_BUS3, &RxMsg);
RxMsg.Id = 0x4D4; //
CAN_UserWrite(CAN_BUS3, &RxMsg);
LED_toggleCAN3 ^= 1;
if (LED_toggleCAN3)
{
HW_SetLED(HW_LED_CAN3, HW_LED_OFF);
}
else
{
HW_SetLED(HW_LED_CAN3, HW_LED_GREEN);
}
}
} // CAN_user read 2
} //while 1