STMicroelectronics / STM32CubeH7

STM32Cube MCU Full Package for the STM32H7 series - (HAL + LL Drivers, CMSIS Core, CMSIS Device, MW libraries plus a set of Projects running on all boards provided by ST (Nucleo, Evaluation and Discovery Kits))
https://www.st.com/en/embedded-software/stm32cubeh7.html
Other
479 stars 298 forks source link

FDCAN FDCAN_RxHeaderTypeDef.data_length is always 0 #291

Closed cstyx closed 2 weeks ago

cstyx commented 1 month ago

Describe the set-up

Describe the bug

How To Reproduce



To reproduce this issue the test project attached at https://github.com/STMicroelectronics/STM32CubeH7/issues/292 can be used
ALABSTM commented 1 month ago

Hi @cstyx,

Thank you for this report too. please refer to my other comment. The two issues may be related.

With regards,

cstyx commented 1 month ago

Hi @ALABSTM,

as mentioned the content of the FDCAN_RxHeaderTypeDef property data_length as provided by HAL_FDCAN_GetRxMessage() is always 0x0000.

Regards

KRASTM commented 3 weeks ago

Hello @cstyx,

Could you please share more details, like screenshots of FDCAN_RxHeaderTypeDef when the problem occurs. In my tests with your project, the data_length property consistently shows a value other than 0.

with regards

cstyx commented 3 weeks ago

Hi @KRASTM

I attached a screen shots of the H723 sender. First is the tx_header and p_can_data as given to function HAL_FDCAN_AddMessageToTxFifoQ(p_hcan, &tx_header, p_can_data) containing 4 Bytes of data as indicated by DLC = 4

CANFD - H723 - txheader 4 byte data

th second one is the same message measured on the CAN BUS but the DLC seems to be 0 and data is already missing

CANFD - H723 - txheader 4 byte data - measured

cstyx commented 3 weeks ago

Hi @KRASTM

I think I found the error at FW_H7 V1.11.1 file stm32h7xx_hal_fdcan.c in function static void FDCAN_CopyMessageToRAM(FDCAN_HandleTypeDef *hfdcan, FDCAN_TxHeaderTypeDef *pTxHeader, uint8_t *pTxData, uint32_t BufferIndex)

at code line

for (ByteCounter = 0; ByteCounter < DLCtoBytes[pTxHeader->DataLength >> 16]; ByteCounter += 4U)

CANFD - H723 - txheader DLC 4 byte

For CAN classic and CANFD the DLC for 4 bytes is "4" but this line shifts it 16 bit to the right so it will be always 0. The following for loop won't be entered and no data will be copied at all. Only TxElementW2 still holds the right data length of "4" but that doesn't seem to matter.

KRASTM commented 3 weeks ago

Hello @cstyx,

I don't understand, at first, you mentioned that you used FW_H7 V1.11.2, and now you suspect an error in FW_H7 V1.11.1!

Since the actual version of the FW_H7 is V1.11.2, and there were some updates related to FDCAN, include that line of code. So, I recommend you, to use the last version.

Thank you for your contribution, please allow me to close this thread.

with regards,