STMicroelectronics / STM32CubeG4

STM32Cube MCU Full Package for the STM32G4 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
182 stars 98 forks source link

FDCAN Timeout after a long (days) run. #9

Closed paoloteti closed 4 years ago

paoloteti commented 4 years ago

Describe the set-up

Describe the bug FDCAN Timeout after a long (days) run.

How To Reproduce

  1. Indicate the global behavior of your application project. No FDCAN Timeout

  2. The modules that you suspect to be the cause of the problem (Driver, BSP, MW ...). FDCAN driver (stm32g4xx_hal_fdcan.c)

  3. The use case that generates the problem. Long (days) run.

Additional context In this piece of code if tickstart is 0xFFFFFFFF and a Tick ISR occur in the middle and so the next call to HAL_GetTick() returns 0 the resulting timeout check return a timeout event.

  tickstart = HAL_GetTick();

  /* Check Sleep mode acknowledge */
  while ((hfdcan->Instance->CCCR & FDCAN_CCCR_CSA) == FDCAN_CCCR_CSA)
  {
    if ((HAL_GetTick() - tickstart) > FDCAN_TIMEOUT_VALUE)
ALABSTM commented 4 years ago

Hi @paoloteti,

Thank you for this detailed report. it has been forwarded to our development teams. I will be back to you as soon as they provide me with feedback.

Thank you once more. Take care and stay safe.

With regards,

ALABSTM commented 4 years ago

Hi @paoloteti,

According to our development teams, the case you are describing does not lead to a timeout. Indeed, if:

The difference would give (0x00000000 - 0xFFFFFFFF) = 0x00000000 + 0x00000001 = 0x00000001 Where 0x00000001 is the two's complement of 0xFFFFFFFF.

The result is not greater than FDCAN_TIMEOUT_VALUE. Thus no timeout occurs.

In case you had a timeout, the cause must be something else.

Thank you,

ALABSTM commented 4 years ago

ST Internal Reference: 66832