cancel
Showing results for 
Search instead for 
Did you mean: 

CAN Communication Issue

SriramK34
Associate

Hi,

I am using STM32F446RE Nucleo and a Peak CAN Usb to test the CAN functionality of the microcontroller. I have connected the Microcontroller to a CAN Transceiver (TJA1050) and added a 120ohm resistor between the CANH and CANL line. I have attached the config of the CAN hardware below

 

  hcan1.Instance = CAN1;
  hcan1.Init.Prescaler = 42;
  hcan1.Init.Mode = CAN_MODE_NORMAL;
  hcan1.Init.SyncJumpWidth = CAN_SJW_1TQ;
  hcan1.Init.TimeSeg1 = CAN_BS1_2TQ;
  hcan1.Init.TimeSeg2 = CAN_BS2_1TQ;
  hcan1.Init.TimeTriggeredMode = DISABLE;
  hcan1.Init.AutoBusOff = DISABLE;
  hcan1.Init.AutoWakeUp = DISABLE;
  hcan1.Init.AutoRetransmission = DISABLE;
  hcan1.Init.ReceiveFifoLocked = DISABLE;
  hcan1.Init.TransmitFifoPriority = DISABLE;

 

When I transmit a message using the Peak CAN, I get  "Frame stuff error (Rx)". I have already attempted to

  • Change the baud rate
  • Remove the resistor
  • Tried a different Peak CAN
  • Changed the Transceiver (3 times)

 

Is the issue from the Transceiver or the microcontroller? Is there any way to check the functionality of the transceiver?

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
SofLit
ST Employee

Hello @SriramK34  and welcome to the community,

  hcan1.Init.Prescaler = 42;
  hcan1.Init.TimeSeg1 = CAN_BS1_2TQ;
  hcan1.Init.TimeSeg2 = CAN_BS2_1TQ;

These are very bad config parameters: BS1 is very low and < BS2.

Need to decrease the prescaler as much as possible and increase BS1 and BS2 as much as possible to fit your bitrate where BS1 = ~(70% to 85%) (BS1+BS2).

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.

View solution in original post

1 REPLY 1
SofLit
ST Employee

Hello @SriramK34  and welcome to the community,

  hcan1.Init.Prescaler = 42;
  hcan1.Init.TimeSeg1 = CAN_BS1_2TQ;
  hcan1.Init.TimeSeg2 = CAN_BS2_1TQ;

These are very bad config parameters: BS1 is very low and < BS2.

Need to decrease the prescaler as much as possible and increase BS1 and BS2 as much as possible to fit your bitrate where BS1 = ~(70% to 85%) (BS1+BS2).

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.