Skip to main content
Visitor II
June 26, 2014
Solved

STm32CubeMX bug: CAN2 wrong configuration

  • June 26, 2014
  • 3 replies
  • 1412 views
Posted on June 26, 2014 at 16:31

Hi,

I tried to configure my STm32F207 using the ''Cube'' to use the CAN2 and I found a bug. This is the initialization code generated by the ''Cube'':

void
HAL_CAN_MspInit(CAN_HandleTypeDef* hcan)
{
GPIO_InitTypeDef GPIO_InitStruct;
if
(hcan->Instance==CAN2)
{
/* Peripheral clock enable */
__CAN2_CLK_ENABLE();
/**CAN2 GPIO Configuration 
PB12 ------> CAN2_RX
PB13 ------> CAN2_TX 
*/
GPIO_InitStruct.Pin = GPIO_PIN_12|GPIO_PIN_13;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_LOW;
GPIO_InitStruct.Alternate = GPIO_AF9_CAN2;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* Peripheral interrupt init*/
/* Sets the priority grouping field */
HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_0);
HAL_NVIC_SetPriority(CAN2_RX1_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(CAN2_RX1_IRQn);
/* Sets the priority grouping field */
HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_0);
HAL_NVIC_SetPriority(CAN2_RX0_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(CAN2_RX0_IRQn);
}
}

The code lacks in activation of the clock for CAN1, since a few registers are common between the two peripherals:

__CAN1_CLK_ENABLE();

    This topic has been closed for replies.
    Best answer by mƎALLEm

    Hello @Ddu P 

    Fixed in the latest version of CubeMx 6.12.0

    3 replies

    ST Employee
    July 21, 2014
    Posted on July 21, 2014 at 19:30

    Bug is confirmed. Thank you for reporting this issue. This will be fixed in a next release.

    Explorer
    February 5, 2024

    This bug is still present in 2024. STM32F413.

    Technical Moderator
    February 5, 2024

    Hello @Ddu P ,

    Thank you for reporting this. It could be related to the device as with F7 CAN1 is enabled.

    The internal ticket 172642 has been opened to fix the issue.

    mƎALLEmAnswer
    Technical Moderator
    July 5, 2024

    Hello @Ddu P 

    Fixed in the latest version of CubeMx 6.12.0