cancel
Showing results for 
Search instead for 
Did you mean: 

EWGF (Error Warning Flag) intermittently set at 1 Mbps CAN on STM32L4 / STM32F4 – works fine at 500 kbps

Chandana_Arava
Associate II

We are facing an intermittent EWGF (Error Warning Flag) issue during CAN communication at 1 Mbps on multiple STM32 MCUs. The same hardware and software setup works reliably at 500 kbps without any CAN warnings.


MCUs Used

  • STM32L443VCT6

  • STM32L443CCT6

  • STM32F437ZGT6

All devices communicate together on the same CAN bus.


Issue Details

  • When CAN bit rate is configured to 1 Mbps, the EWGF bit in CAN_ESR register gets set intermittently

  • Communication does not stop immediately, but error counters increase over time

  • At 500 kbps, the issue is not observed

  • Same CAN transceivers, wiring, and termination are used


CAN Configuration

Common Settings

  • CAN peripheral clock: 24 MHz

  • GPIO speed for CAN TX/RX pins: High speed

  • Same clock source and configuration across all MCUs

    For Bit Rate 500KHz

    CANx->BTR = CAN_TSEG1(12) | CAN_TSEG2(1) | CAN_BRP(2) |CAN_SJW(0);

     

    For Bit Rate 1MHz (Tried for different TQ , but still getting CAN warning)

    TQ per bit = 8 TQ

    CANx->BTR = CAN_TSEG1(5) | CAN_TSEG2(0) | CAN_BRP(2) |CAN_SJW(0);

     

    TQ per bit = 12 TQ

    CANx->BTR = CAN_TSEG1(7) | CAN_TSEG2(2) | CAN_BRP(1) |CAN_SJW(0);

     

    TQ per bit = 24 TQ

    CANx->BTR = CAN_TSEG1(14) | CAN_TSEG2(7) | CAN_BRP(0) |CAN_SJW(0);





1 REPLY 1
mƎALLEm
ST Employee

Hello,

You didn't tell:

1- What is the clock source you have used? HSI or an external Crystal? If HSI that's not recommended you need to use a precise clock source over temperature and other constraints such as a crystal.

2- What is the length of your CAN bus? The maximum bitrate you can reach depends on your bus length:

CAN bitrate

Maximum bus length (m)

1 Mbit/s

35

800 kbit/s

50

500 kbit/s

100

250 kbit/s

250

125 kbit/s

500

50 kbit/s

1000

20 kbit/s

2500

10 kbit/s

5000

3- Did you use a twisted pair for a long bus length? 

4- Did you connect two terminating resistors of 120ohm at both sides of the CAN bus?

Please refer to the following knowledge base articles:

CAN (bxCAN) bit time configuration on STM32 MCUs

Using CAN (bxCAN) in Normal mode with STM32 microcontrollers (Part 1)

Using CAN (bxCAN) in Normal mode with STM32 microcontrollers (Part 2)

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.