cancel
Showing results for 
Search instead for 
Did you mean: 

Cube F7 1.7.0 CAN library bug?

AndreaC
Associate III
Posted on May 02, 2017 at 16:10

Hello,

today I updated my Cube libraries to the last release and I found that in stm32f7xx_hal_can.c the HAL_UNLOCK is missing, in HAL_CAN_Receive_IT().

HAL_StatusTypeDef HAL_CAN_Receive_IT(CAN_HandleTypeDef* hcan, uint8_t FIFONumber)
{
 /* Check the parameters */
 assert_param(IS_CAN_FIFO(FIFONumber));
 
 /* Check if CAN state is not busy for RX FIFO0 */
 if((FIFONumber == CAN_FIFO0) && ((hcan->State == HAL_CAN_STATE_BUSY_RX0) || \
 (hcan->State == HAL_CAN_STATE_BUSY_TX_RX0) || \
 (hcan->State == HAL_CAN_STATE_BUSY_RX0_RX1) || \
 (hcan->State == HAL_CAN_STATE_BUSY_TX_RX0_RX1)))
 {
 return HAL_BUSY;
 }
 /* Check if CAN state is not busy for RX FIFO1 */
 if((FIFONumber == CAN_FIFO1) && ((hcan->State == HAL_CAN_STATE_BUSY_RX1) || \
 (hcan->State == HAL_CAN_STATE_BUSY_TX_RX1) || \
 (hcan->State == HAL_CAN_STATE_BUSY_RX0_RX1) || \
 (hcan->State == HAL_CAN_STATE_BUSY_TX_RX0_RX1)))
 {
 return HAL_BUSY;
 }
 /* Process locked */
 __HAL_LOCK(hcan);
 /* Change CAN state */
 if(FIFONumber == CAN_FIFO0)
 {
 switch(hcan->State)
 {
 case(HAL_CAN_STATE_BUSY_TX):
 hcan->State = HAL_CAN_STATE_BUSY_TX_RX0;
 break;
 case(HAL_CAN_STATE_BUSY_RX1):
 hcan->State = HAL_CAN_STATE_BUSY_RX0_RX1;
 break;
 case(HAL_CAN_STATE_BUSY_TX_RX1):
 hcan->State = HAL_CAN_STATE_BUSY_TX_RX0_RX1;
 break;
 default: /* HAL_CAN_STATE_READY */
 hcan->State = HAL_CAN_STATE_BUSY_RX0;
 break;
 }
 }
 else /* FIFONumber == CAN_FIFO1 */
 {
 switch(hcan->State)
 {
 case(HAL_CAN_STATE_BUSY_TX):
 hcan->State = HAL_CAN_STATE_BUSY_TX_RX1;
 break;
 case(HAL_CAN_STATE_BUSY_RX0):
 hcan->State = HAL_CAN_STATE_BUSY_RX0_RX1;
 break;
 case(HAL_CAN_STATE_BUSY_TX_RX0):
 hcan->State = HAL_CAN_STATE_BUSY_TX_RX0_RX1;
 break;
 default: /* HAL_CAN_STATE_READY */
 hcan->State = HAL_CAN_STATE_BUSY_RX1;
 break;
 }
 }
 /* Set CAN error code to none */
 hcan->ErrorCode = HAL_CAN_ERROR_NONE;
 /* Enable interrupts: */
 /* - Enable Error warning Interrupt */
 /* - Enable Error passive Interrupt */
 /* - Enable Bus-off Interrupt */
 /* - Enable Last error code Interrupt */
 /* - Enable Error Interrupt */
 /* - Enable Transmit mailbox empty Interrupt */
 __HAL_CAN_ENABLE_IT(hcan, CAN_IT_EWG |
 CAN_IT_EPV |
 CAN_IT_BOF |
 CAN_IT_LEC |
 CAN_IT_ERR |
 CAN_IT_TME);
 if(FIFONumber == CAN_FIFO0)
 {
 /* Enable FIFO 0 overrun and message pending Interrupt */
 __HAL_CAN_ENABLE_IT(hcan, CAN_IT_FOV0 | CAN_IT_FMP0);
 }
 else
 {
 /* Enable FIFO 1 overrun and message pending Interrupt */
 __HAL_CAN_ENABLE_IT(hcan, CAN_IT_FOV1 | CAN_IT_FMP1);
 }
 __HAL_UNLOCK(hcan); // <------- THIS LINE WAS MISSING
 /* Return function status */
 return HAL_OK;
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

I added it (at line 1095 of the original file) and now everything works, apparently.

Best Regards,

Andrea

#bug #cube #f7 #can
5 REPLIES 5
Imen.D
ST Employee
Posted on May 02, 2017 at 18:09

Hi

Coccon.Andrea,

I reported this issue internally and I come back to yousoon with the taken actions/explanation if needed.

Thanks

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Jos Poelmans
Associate II
Posted on May 10, 2017 at 12:25

in cube version 1.6.0

the unlock is place before

if

(

FIFONumber

==

CAN_FIFO0

)

{

   

/* Enable FIFO 0 overrun and message pending Interrupt */

   

__HAL_CAN_ENABLE_IT

(

hcan

,

CAN_IT_FOV0

|

CAN_IT_FMP0

)

;

 

}

 

else

 

{

   

/* Enable FIFO 1 overrun and message pending Interrupt */

   

__HAL_CAN_ENABLE_IT

(

hcan

,

CAN_IT_FOV1

|

CAN_IT_FMP1

)

;

 

}

and not after

this code

I don't no wat is better.

Tiago Malheiro
Associate II
Posted on May 13, 2017 at 16:35

Hi,

I had the same issue and fixed it the same way!

best,

Tiago

Posted on July 11, 2018 at 14:21

Hello,

The HAL CAN driver is reworked with the STM32CubeF7 version 1.9.0 to bypass limitations on CAN present with previous HAL CAN driver versions.

So, the new HAL CAN driver is the recommended version to use. It is located as usual in Drivers/STM32F7xx_HAL_Driver/Src and Drivers/

STM32F7xx_HAL_Driver

/Inc folders.

It can be enabled through switch HAL_CAN_MODULE_ENABLED in stm32f7xx_hal_conf.h

The legacy HAL CAN driver is also present in the release in Drivers/STM32F7xx_HAL_Driver/Src/Legacy and Drivers/

STM32F

7

xx_HAL_Driver

/Inc/Legacy folders for software compatibility reasons.

Its usage is not recommended as deprecated. It can however be enabled through switch HAL_CAN_LEGACY_MODULE_ENABLED in stm32f7xx_hal_conf.h

With Regards,

Imen.

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Posted on July 11, 2018 at 17:38

Hi Imen,

thanks for your support.

BR,

Andrea

Il giorno mer 11 lug 2018 alle ore 14:30 Imen D <

st-microelectronics@jiveon.com> ha scritto:

STMicroelectronics Community

<https://community.st.com/?et=watches.email.thread>

Re: Cube F7 1.7.0 CAN library bug?

reply from Imen D

<

MCUs Forum* - View the full discussion

<https://community.st.com/0D70X000006Sv6FSAS