RX63T CAN transmission error (Stuff error, Format Error)

Hi

 

I am facing some CAN transmission error (stuff and format error) on the CAN bus(CANoe) when I use sample code (an_r01an2062eg0200_rx63t_rsk) with my starter kit (RSKRX63T144).

 

Even I tried to use both polling or interrupt mode by configuring "USE_CAN_POLL" in config_r_can_rapi.h, it always stuck in one of endless while loop in

api_demo function in api_demo.c due to transmission not completed.

 

uint32_t R_CAN_TxCheck(const uint32_t ch_nr, const uint32_t mbox_nr)

{

uint32_t api_status = R_CAN_OK;

volatile struct st_can __evenaccess * can_block_p;

 

CHECK_MBX_NR

if (ch_nr < MAX_CHANNELS)

{

can_block_p = CAN_CHANNELS[ch_nr];

}

else

{

return R_CAN_BAD_CH_NR ;

}

 

if (can_block_p->MCTL[mbox_nr].BIT.TX.SENTDATA == 0)

api_status = R_CAN_NO_SENTDATA;

else

{

/* Clear SentData flag. */

can_clear_sent_data (ch_nr, mbox_nr);

}

return api_status;

}

 

I also use 120 ohm termination resistor at the CANCASE XL.

 

Based on starter kit, external crystal frequency is 12 MHZ.

Current bit timing register setting is as follow:

 

#define CAN_BRP 4

#define CAN_TSEG1 15

#define CAN_TSEG2 8

#define CAN_SJW 2

 

Clocking setting info are as follow:

/* Configure the clocks as follows -

Clock Description Frequency

----------------------------------------

Extal frequency....................12MHz

PLL Clock frequency...............192MHz

System Clock Frequency.............96MHz

Peripheral Module Clock A..........96MHz

Peripheral Module Clock B..........48MHz

Peripheral Module Clock C..........96MHz

Peripheral Module Clock D..........48MHz

FlashIF Clock......................48MHz

External Bus Clock.................48MHz */

Can you advise me how I can fix this CAN transmission error issue?

 

Many Thanks

  • You have a CAN sample point of around 67 %. You can alter this value by adding (or subtracting) an integer to CAN_TSEG1 and by subtracting (or adding) the same value from CAN_TSEG2. This value should be around equal on all CAN bus participants:

    CAN_sample_point = (1 + CAN_TSEG1) / (1 + CAN_TSEG1 + CAN_TSEG2)
  • Thanks for your reply .

    I tried to match CAN sampling point between our board and CANoe by varying CAN_BRP, CAN_TSEG1, CAN_TSEG2 and CAN_SJW for 1Bit (8tq or 16 tq) with different CAN sampling rate.

    fcan = 48MHz, 500kbps,

    Tested 4 scenarios

    #define CAN_BRP 12
    1 Bit = 8tq, SS=1, TSEG1 =4 , TSEG2 =3, SJW=1, Sampling point 62.50%
    1Bit = 8tq, SS=1, TSEG1=5, TSEG2 =2, SJW=1, Sampling point 75%

    #define CAN_BRP 6
    1Bit = 16 tq, SS=1, TSEG1 =10 , TSEG2 =5, SJW=1, Sampling point 68.75%
    1Bit = 16 tq, SS=1, TSEG1 =11 , TSEG2 =4, SJW=1, Sampling point 75%

    Is it ok?

    Beside CAN bit timing issue, is there any other possibility that caused this issue?

    Many Thanks
    Phyo
  • In reply to ppp123:

    > Beside CAN bit timing issue, is there any other possibility that caused this issue?

    Both ends of the CAN bus must be terminated with a 120 Ohm resistor.
  • I changed SJW to 3 and tested it again.
    Now it is able to transmit.

    Thanks for ur support.