cancel
Showing results for 
Search instead for 
Did you mean: 

STm32CubeMX bug: CAN2 wrong configuration

Walter Lucetti
Associate III
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();

1 ACCEPTED SOLUTION

Accepted Solutions
SofLit
ST Employee

Hello @Ddu P 

Fixed in the latest version of CubeMx 6.12.0

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

View solution in original post

4 REPLIES 4
stm32cube-t
Senior III
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.

Ddu P
Associate III

This bug is still present in 2024. STM32F413.

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.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
SofLit
ST Employee

Hello @Ddu P 

Fixed in the latest version of CubeMx 6.12.0

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.