Incompatibility in CAN implementation between HAL and SPL due to possible bug in HAL
- February 25, 2022
- 4 replies
- 2220 views
Hi
We are trying to communicate between an F407 Discovery using SPL's CAN implementation and F756 Nucleo running HAL's CAN implementation.
Here is the calculation for time quanta and Baud rate...
Baudrate = 1 / Nominal Bit Time
Nominal Bit Time = 1 x Tq x Tbs1 x Tbs2
Time Quanta(tq) = 1/ (Frequency of CAN APB CLOCK / Prescalar)
Time Quanta(tq) = Period of CAN APB CLOCK x Prescalar
BAUDRATE = 1 / Nominal Bitrate (Time for one Bit)
Nominal Bitrate or Nominal BitTime (Time for one Bit) = 1 x Tq x Tbs1 x Tbs2
===============================================
F407 Dicovery Board:
SYS-CLK : 168MHz
APB1 CLK : 42MHz
CAN Prescalar : 7
TImeSeg1 : CAN_BS1_4TQ
TImeSeg2 : CAN_BS2_1TQ
SyncJumpWidth : CAN_SJW_1TQ
Sampling Point : 75%
BAUDRATE : 1MBps
CALCULATION:
tq = 1/(42MHz/7) = 166.667 nS
tBS1 = 4 x tq = 666.667 nS
tBS1 = 1 x tq = 166.667 nS
NominalBitTime = 1 tq + tBS1 + tBS2 = 1uS
Baudrate = 1/NominalBitTime = 1Mbps
samplingpoint (%) = tBS1/(tBS1 + tBS2)*100
(4/5)*100= 75%
===============================================
===============================================
F756 Nucleo Board:
SYS-CLK : 216MHz
APB1 CLK : 54MHz
CAN Prescalar : 9
TImeSeg1 : CAN_BS1_4TQ
TImeSeg2 : CAN_BS2_1TQ
SyncJumpWidth : CAN_SJW_1TQ
Sampling Point : 75%
BAUDRATE : 1MBps
CALCULATION:
tq = 1/(54MHz/9) = 166.66 nS
tBS1 = 4 x tq = 666.667 nS
tBS1 = 1 x tq = 166.667 nS
NominalBitTime = 1 tq + tBS1 + tBS2 = 1uS
Baudrate = 1/NominalBitTime = 1Mbps
samplingpoint (%) = tBS1/(tBS1 + tBS2)*100
(4/5)*100= 75%
Code for both is attached. No messages leave F407 or F756. Something very basic is wrong or the problem lies deep within HAL. Any help will be greatly appreciated.
Both codes are attached.
Regards
Srinath
