CAN Communication Issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-03 10:13 PM - last edited on ‎2024-11-03 11:28 PM by mƎALLEm
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!
Solved! Go to Solution.
- Labels:
-
CAN
-
STM32F4 Series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-03 11:27 PM
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).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2024-11-03 11:27 PM
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).
