AnsweredAssumed Answered

STm32CubeMX bug: CAN2 wrong configuration

Question asked by Lucetti.Walter on Jun 26, 2014
Latest reply on Jul 21, 2014 by STM32Cube-T

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;
    /* Peripheral clock 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_SetPriority(CAN2_RX1_IRQn, 0, 0);
    /* Sets the priority grouping field */
    HAL_NVIC_SetPriority(CAN2_RX0_IRQn, 0, 0);

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