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
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();

Outcomes