2013-07-04 06:18 AM
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 );} #can #problem #stm32f42013-07-04 06:41 AM
Problem solved :
RCC_APB1PeriphClockCmd( RCC_APB1Periph_CAN2, ENABLE ); --> RCC_APB1PeriphClockCmd(( RCC_APB1Periph_CAN1 | RCC_APB1Periph_CAN2 ), ENABLE ); CAN_FilterInitStructure.CAN_FilterNumber = 0u; --> CAN_FilterInitStructure.CAN_FilterNumber = 14u;2013-07-04 07:12 AM
The filter are certainly one of the issues, though I seem to recall you can change the split between the controllers.