Automatic bitrate detection on a CAN network

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Apr 24, 2017 by Sander Verhage
Content originally posted in LPCWare by ALU on Tue Feb 25 03:01:08 MST 2014
Hello everybody,

I'm trying to set up an automatic bit rate detection (LPC1778 controller + LOM).
Testing all valid bit rates works fine as long as more than one other CAN device is active on my network.
I haven't managed to detect a bit rate when LPC1778 and the sending CAN device are the only active devices.
(OK, each transmitted Message needs to be acknowledged by at least one other CAN device. )
But there is a time when the sending CAN device reaches error-warning limit and may not destroy the message it transmits.
This message should be detected by LPC1778, but it is not?!? (It works for other CAN-Controllers.)
What's the way to detect a valid bit rate when only the detecting device and one sending CAN-Device are active?
My code...
(Cyclic call of BSP_CAN_Autobaud(), CAN-Controller initialized in listen only mode)

// Automatic bitrate detection...
// Return values: 0..8 = index of detected bitrate , 10 detection in progress, >= 90 Error.
BYTE BSP_CAN_Autobaud(void)
    //check status of Receive Buffer
    if ( (LPC_CAN1->SR & CAN1SR_RBS ) != 0  ||
         (LPC_CAN1->GSR & CAN1SR_RBS ) != 0    )
    { // Valid Message received...
        LPC_CAN1->CMR = CAN1CMR_RRB;
        return g_BS_CAN.eBaudrate;
        if( (BS_GetMsTicks()-g_BS_CAN.ulAutoBaudStartTime) > BS_CAN_AUTOBAUD_TIMEOUT_MS)
        { // No messages received, try next baudrate...

Thanks for any hint.