2014-06-26 07:31 AM
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();
Solved! Go to Solution.
2024-07-05 07:41 AM
Hello @Ddu P
Fixed in the latest version of CubeMx 6.12.0
2014-07-21 10:30 AM
2024-02-05 09:09 AM
This bug is still present in 2024. STM32F413.
2024-02-05 11:38 AM
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.
2024-07-05 07:41 AM
Hello @Ddu P
Fixed in the latest version of CubeMx 6.12.0