STM32F4 HAL CAN DUAL use,.. FIFO1 callback not invoked but frame is in FIFO1
Hey Guys,
I have a problem using the CAN1 and CAN2 in dual use on the STM32F2427ZIT6 (custom board).
Hereby CAN1 is configured for FIFO0 Interrupt and,
CAN2 is configured for FIFO1 interrupt.
I managed to transmit and receive frames via CAN1. Also I manged to transmit frames with CAN2.
Furthermore if I send frames with the correct filter ID to CAN2 it does arrive in the FIFO1 memory.(I can see it in the hcan2 handler instance with the RF1R bit switch to 1. Also I do see the frame data in the sFIFOMailbox[1] in the RDLR and RDHR fields.)
The problem is that the HAL_CAN_RxFifo1MsgPendingCallback is not called. Whereas when I use CAN1 the HAL_CAN_RxFifo0MsgPendingCallback works fine. So because I do receive the frame in the FIFO I think the filter settings are correct. Also the new firmware automatically is assigning the CAN1 handler for the filter settings in the ConfigFilter function.
Firmware version 1.21. is used.
my can_init function:
void Com::init_can(interface_can* _p_interface_can){
CAN_FilterTypeDef myFilter;
myFilter.FilterBank = 0; //ID 0-13 for CAN1, 14+ is CAN2 myFilter.FilterMode = CAN_FILTERMODE_IDMASK; myFilter.FilterScale = CAN_FILTERSCALE_32BIT; myFilter.FilterIdHigh = 0x100<<5; //11-bit ID, in top bits myFilter.FilterIdLow = 0x0000; myFilter.FilterMaskIdHigh = 0x700 << 5; // resolves as 0x01xx //before it was myFilter.FilterMaskIdHigh = 0xff<<5; myFilter.FilterMaskIdLow = 0x0000; myFilter.FilterFIFOAssignment = CAN_RX_FIFO0; myFilter.FilterActivation = ENABLE; myFilter.SlaveStartFilterBank = 14; HAL_CAN_ConfigFilter(can_handles_array[0],&myFilter); // ------------------------------------- // // CAN2 Config // Filter IDs from 0x200 -> 0x2FF will be received myFilter.FilterBank = 18; //ID 0-13 for CAN1, 14+ is CAN2 myFilter.FilterMode = CAN_FILTERMODE_IDMASK; myFilter.FilterScale = CAN_FILTERSCALE_32BIT; myFilter.FilterIdHigh = 0x200<<5; //11-bit ID, in top bits myFilter.FilterIdLow = 0x0000; myFilter.FilterMaskIdHigh = 0x700 << 5; // resolves as 0x01xx myFilter.FilterMaskIdLow = 0x0000; myFilter.FilterFIFOAssignment = CAN_RX_FIFO1; myFilter.FilterActivation = ENABLE; myFilter.SlaveStartFilterBank = 14; HAL_CAN_ConfigFilter(can_handles_array[1],&myFilter); HAL_CAN_Start(can_handles_array[0]); HAL_CAN_Start(can_handles_array[1]); HAL_CAN_ActivateNotification(can_handles_array[0], CAN_IT_RX_FIFO0_MSG_PENDING); HAL_CAN_ActivateNotification(can_handles_array[1], CAN_IT_RX_FIFO1_MSG_PENDING);}
void HAL_CAN_RxFifo1MsgPendingCallback(CAN_HandleTypeDef *hcan)
{ /* Get RX message */ HAL_CAN_GetRxMessage(hcan, CAN_RX_FIFO1, &RxHeader_B2,RxData_B2); BaseType_t xHigherPriorityTaskWoken = pdFALSE; xSemaphoreGiveFromISR(xBinarySemaphore_CAN2Interrupt, &xHigherPriorityTaskWoken ); portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );}In the image you can see the CAN2 Bits after receiving the frame. The callback function was not invoked.
