STMicroelectronics / STM32CubeG0

STM32Cube MCU Full Package for the STM32G0 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))
Other
165 stars 75 forks source link

stm32g0xx_hal_fdcan.c undocumented change to 'pTxHeader->DataLength' #47

Closed ryedwards closed 9 months ago

ryedwards commented 9 months ago

When updating a project to the latest HAL I was getting a hard fault when trying to TX a CAN message with my exisiting code base.

The differences exisit between 1.6.1 and 1.6.2. A diff between the files confirms.

Reviewing the call stack the program was failing at this command: / Write Tx payload to the message RAM / for (ByteCounter = 0; ByteCounter < DLCtoBytes[pTxHeader->DataLength]; ByteCounter += 4U)

This was failing because the DataLength was out of range.

I went back to a saved version of my code to compare that area of code. In the previous version this is what appears: / Write Tx payload to the message RAM / for (ByteCounter = 0; ByteCounter < DLCtoBytes[pTxHeader->DataLength >> 16U]; ByteCounter += 4U)

It appears between the two versions the DLC was changed from the shifted value to the absolute value. This should be documented as it will eventually impact all of the DLC areas of my code.

RJMSTM commented 9 months ago

Hello @ryedwards,

Firstly, I confirm that there is an error in the release note, as the message for this change is missing. We apologize for any inconvenience this may have caused, this will be fixed and integrated ASAP.

Second, in regard to the hard fault that was detected when you were trying to TX a CAN message, have you updated the header file because the change is also in stm32g0_hal_fdan.h image

Regards, Rania

RJMSTM commented 9 months ago

Fixed in 11bf550bba048e55fb465842fa0b2d1f13660868