AnsweredAssumed Answered

STM32F4xx CAN2 problem

Question asked by ClementGrosjean on Jul 4, 2013
Latest reply on Jul 4, 2013 by Clive One
Hi,

I work with an STM32F405 and i cannot use the CAN2. 

Now, I do some tests on the discovery board on an STM32F407. And with the same code developed for CAN2 used with CAN1 all seems good. 

I think, that I have forgotten something, but what?

This is my can configuration :

static void CAN_Configuration( void )
{
  
  RCC_APB1PeriphClockCmd( RCC_APB1Periph_CAN2, ENABLE );
  
  CAN_InitTypeDef       CAN_InitStructure;
  CAN_FilterInitTypeDef CAN_FilterInitStructure;
           
  // CAN register init 
  CAN_DeInit( CAN2 );
  CAN_StructInit( &CAN_InitStructure );
  
  // CAN cell init 
  CAN_InitStructure.CAN_TTCM      = DISABLE;
  CAN_InitStructure.CAN_ABOM     = ENABLE;
  CAN_InitStructure.CAN_AWUM    = ENABLE;
  CAN_InitStructure.CAN_NART      = DISABLE;
  CAN_InitStructure.CAN_RFLM      = DISABLE;
  CAN_InitStructure.CAN_TXFP       = DISABLE;
  CAN_InitStructure.CAN_Mode       = CAN_Mode_LoopBack; /* todo CAN_Mode_Normal */
  // CAN Baudrate = 175kbps (CAN clocked at 42 MHz) 
  CAN_InitStructure.CAN_SJW        = CAN_SJW_1tq;
  CAN_InitStructure.CAN_BS1         = CAN_BS1_6tq;
  CAN_InitStructure.CAN_BS2         = CAN_BS2_8tq;
  CAN_InitStructure.CAN_Prescaler  = 16u;
 
  CAN_Init( CAN2, &CAN_InitStructure );
  
  // Activate CAN in debug mode
  CAN_DBGFreeze( CAN2, DISABLE );


  // CAN filter init 
  CAN_FilterInitStructure.CAN_FilterNumber         = 0u;
  CAN_FilterInitStructure.CAN_FilterMode           = CAN_FilterMode_IdMask;
  CAN_FilterInitStructure.CAN_FilterScale          = CAN_FilterScale_32bit;
  CAN_FilterInitStructure.CAN_FilterIdHigh         = 0x0000u;
  CAN_FilterInitStructure.CAN_FilterIdLow          = 0x0000u;
  CAN_FilterInitStructure.CAN_FilterMaskIdHigh     = 0x0000u;
  CAN_FilterInitStructure.CAN_FilterMaskIdLow      = 0x0000u;  
  CAN_FilterInitStructure.CAN_FilterFIFOAssignment = 0u;
  CAN_FilterInitStructure.CAN_FilterActivation     = ENABLE;
  CAN_FilterInit( &CAN_FilterInitStructure );
}

Outcomes