2016-02-19 03:32 AM
HI,
I try to config Filters for two can bus on STM32F105, but i have strange problems .When i config filter with CAN2SB = 14 to specify start point of filters for CAN2, the interrupts RX0 and RX1, not work.If i config Filters with CAN2SB = 0, interrupts RX0 and RX1 work both.Sorry for my english.{
CAN_FilterConfTypeDef sFilterConfig; // CAN1 filter init sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK; sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT; sFilterConfig.FilterIdHigh = 0x0000; sFilterConfig.FilterIdLow = 0x0000; sFilterConfig.FilterMaskIdHigh = 0x0000; sFilterConfig.FilterMaskIdLow = 0x0000; sFilterConfig.FilterFIFOAssignment = CAN_FIFO0; sFilterConfig.FilterActivation = ENABLE;sFilterConfig.FilterNumber = 0;
if (HAL_CAN_ConfigFilter( &hcan1, &sFilterConfig ) != HAL_OK) { Error_Handler(); } // CAN2 filter init sFilterConfig.BankNumber = 14; // start bank filters for can2 sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK; sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT; sFilterConfig.FilterIdHigh = 0x0000; sFilterConfig.FilterIdLow = 0x0000; sFilterConfig.FilterMaskIdHigh = 0x0000; sFilterConfig.FilterMaskIdLow = 0x0000; sFilterConfig.FilterFIFOAssignment = CAN_FIFO0; sFilterConfig.FilterActivation = ENABLE;sFilterConfig.FilterNumber = 14;
if (HAL_CAN_ConfigFilter( &hcan2, &sFilterConfig ) != HAL_OK){
Error_Handler(); } }2016-02-19 03:51 AM
Perhaps you need to fully initialize the structure in the first instance, as the stacked local variable will contain random junk?
sFilterConfig.BankNumber = 0; // start bank filters for can12016-02-19 07:14 AM
I have already tried, and CAN_FMR register is only one for two can, so it's enought configure it one time before tx or rx !
2016-02-19 08:39 AM
Sorry, I'm not a HAL user.
Perhaps you need to zoom out a level or two, and look at how the CAN controller is being initialized, the pins and the transceiver.