cancel
Showing results for 
Search instead for 
Did you mean: 

Received FDCAN 64bytes data but FDCAN_RxHeader.datalength is 15, is it a bug?

dqsh06
Senior

Split from this thread.

thanks to @Ozone @Karl Yamashita,

this afternoon I have tried to extend can2.0 to canfd with my project of stm32g474vet6.  I found some strange things, I think there may be a bug of stm32g474vet6 fdcan module.

I modifed the FDCAN_TxHeader to FD_Frame and datelength to 64byte. for  FDCAN_RxHeader, almost nothing to modify. then i used an app on PC to send a 64bytes CAN message,  then my code received the 64bytes message and copied to rxbuffer, the rxbuffer had 64bytes data, but FDCAN_RxHeader.datalength is 15. it is not 64. 

i think this is a bug of stm32g474vet6, it received 64bytes data but FDCAN_RxHeader.datalength is 15. I have no can tool now (with used by other people), when i have the can tool, i will take screenshot to show the strange thing.

hello @mƎALLEm @Saket_Om did you meet FDCAN received 64bytes but  FDCAN_RxHeader.datalength is 15? is there some configuration I miss?

 

Thanks a lot!

1 ACCEPTED SOLUTION

Accepted Solutions
mƎALLEm
ST Employee

@dqsh06 wrote:

hello @mƎALLEm @Saket_Om did you meet FDCAN received 64bytes but  FDCAN_RxHeader.datalength is 15? is there some configuration I miss?


This is not a bug and the information is provided in the reference manual RM0440 Rev 9:

mALLEm_1-1756132516544.png

DLC=15 means 64 bytes!

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

2 REPLIES 2
mƎALLEm
ST Employee

@dqsh06 wrote:

hello @mƎALLEm @Saket_Om did you meet FDCAN received 64bytes but  FDCAN_RxHeader.datalength is 15? is there some configuration I miss?


This is not a bug and the information is provided in the reference manual RM0440 Rev 9:

mALLEm_1-1756132516544.png

DLC=15 means 64 bytes!

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.
Karl Yamashita
Principal

When using ST's data structure for FDCAN_RxHeaderTypeDef, you should look what the reference is for DataLength, which they reference FDCAN_data_length_code 

/**
  * @brief  FDCAN Rx header structure definition
  */
typedef struct
{
  uint32_t Identifier;            /*!< Specifies the identifier.
                                       This parameter must be a number between:
                                        - 0 and 0x7FF, if IdType is FDCAN_STANDARD_ID
                                        - 0 and 0x1FFFFFFF, if IdType is FDCAN_EXTENDED_ID               */

  uint32_t IdType;                /*!< Specifies the identifier type of the received message.
                                       This parameter can be a value of @ref FDCAN_id_type               */

  uint32_t RxFrameType;           /*!< Specifies the the received message frame type.
                                       This parameter can be a value of @ref FDCAN_frame_type            */

  uint32_t DataLength;            /*!< Specifies the received frame length.
                                        This parameter can be a value of @ref FDCAN_data_length_code     */

  uint32_t ErrorStateIndicator;   /*!< Specifies the error state indicator.
                                       This parameter can be a value of @ref FDCAN_error_state_indicator */

  uint32_t BitRateSwitch;         /*!< Specifies whether the Rx frame is received with or without bit
                                       rate switching.
                                       This parameter can be a value of @ref FDCAN_bit_rate_switching    */

  uint32_t FDFormat;              /*!< Specifies whether the Rx frame is received in classic or FD
                                       format.
                                       This parameter can be a value of @ref FDCAN_format                */

  uint32_t RxTimestamp;           /*!< Specifies the timestamp counter value captured on start of frame
                                       reception.
                                       This parameter must be a number between 0 and 0xFFFF              */

  uint32_t FilterIndex;           /*!< Specifies the index of matching Rx acceptance filter element.
                                       This parameter must be a number between:
                                        - 0 and (SRAMCAN_FLS_NBR-1), if IdType is FDCAN_STANDARD_ID
                                        - 0 and (SRAMCAN_FLE_NBR-1), if IdType is FDCAN_EXTENDED_ID */

  uint32_t IsFilterMatchingFrame; /*!< Specifies whether the accepted frame did not match any Rx filter.
                                         Acceptance of non-matching frames may be enabled via
                                         HAL_FDCAN_ConfigGlobalFilter().
                                         This parameter can be 0 or 1                                    */

} FDCAN_RxHeaderTypeDef;

 

You can see how they defined the values

/** @defgroup FDCAN_data_length_code FDCAN Data Length Code
  * @{
  */
#define FDCAN_DLC_BYTES_0  ((uint32_t)0x00000000U) /*!< 0 bytes data field  */
#define FDCAN_DLC_BYTES_1  ((uint32_t)0x00010000U) /*!< 1 bytes data field  */
#define FDCAN_DLC_BYTES_2  ((uint32_t)0x00020000U) /*!< 2 bytes data field  */
#define FDCAN_DLC_BYTES_3  ((uint32_t)0x00030000U) /*!< 3 bytes data field  */
#define FDCAN_DLC_BYTES_4  ((uint32_t)0x00040000U) /*!< 4 bytes data field  */
#define FDCAN_DLC_BYTES_5  ((uint32_t)0x00050000U) /*!< 5 bytes data field  */
#define FDCAN_DLC_BYTES_6  ((uint32_t)0x00060000U) /*!< 6 bytes data field  */
#define FDCAN_DLC_BYTES_7  ((uint32_t)0x00070000U) /*!< 7 bytes data field  */
#define FDCAN_DLC_BYTES_8  ((uint32_t)0x00080000U) /*!< 8 bytes data field  */
#define FDCAN_DLC_BYTES_12 ((uint32_t)0x00090000U) /*!< 12 bytes data field */
#define FDCAN_DLC_BYTES_16 ((uint32_t)0x000A0000U) /*!< 16 bytes data field */
#define FDCAN_DLC_BYTES_20 ((uint32_t)0x000B0000U) /*!< 20 bytes data field */
#define FDCAN_DLC_BYTES_24 ((uint32_t)0x000C0000U) /*!< 24 bytes data field */
#define FDCAN_DLC_BYTES_32 ((uint32_t)0x000D0000U) /*!< 32 bytes data field */
#define FDCAN_DLC_BYTES_48 ((uint32_t)0x000E0000U) /*!< 48 bytes data field */
#define FDCAN_DLC_BYTES_64 ((uint32_t)0x000F0000U) /*!< 64 bytes data field */

 

 

CANable V3 firmware | CAN-X CAN bus analyzer software for CANable V3 |
TimerCallback tutorial! | UART and DMA Idle with multiple UART instances tutorial!

If you find my solution useful, please click the Accept as Solution so others see the solution.