2024-05-16 12:48 AM - last edited on 2024-05-16 01:16 AM by SofLit
Hello ST community,
I am currently programming an ECU system, using f446re nucleo board. Right now i am trying to communicate with BMS using CAN communication.
So far, everything has been set: CAN Initialization and start, sending works properly.
The issue i am facing is that i cannot receive frames from battery, even though i can communicate with laptop for UDS protocole (Reception works properly in that case), but when i try with the battery, the debug mode doesn't stop at the rx interrupt routine.
I have verified the CANFilter configuration to make sure, i didn't see any mistake, nothing has been changed but i only can communicate with UDS frames and not with batteries.
for example: frame ID 0x586 entering fifo0 with such a filter:
void CAN_Filter_FIFO0(CAN_HandleTypeDef* hcan)
{
CAN_FilterTypeDef canfilterconfig;
canfilterconfig.FilterActivation = CAN_FILTER_ENABLE;
canfilterconfig.FilterBank = 10;
canfilterconfig.FilterFIFOAssignment = CAN_FILTER_FIFO0;
canfilterconfig.FilterIdHigh = 0x580 << 5; // According to the DBC
canfilterconfig.FilterIdLow = 0x0000;
canfilterconfig.FilterMaskIdHigh = 0xfe0<<5;// Calculation of the mask according to the DBC
canfilterconfig.FilterMaskIdLow = 0x0000;
canfilterconfig.FilterMode = CAN_FILTERMODE_IDMASK;
canfilterconfig.FilterScale = CAN_FILTERSCALE_32BIT;
canfilterconfig.SlaveStartFilterBank = 13;
HAL_CAN_ConfigFilter(hcan, &canfilterconfig);
}
Please let me know if anyone has any idea.
Solved! Go to Solution.
2024-05-21 06:11 AM
Alright, found the problem, I was using both fifo0 and fifo1 for receiving whereas i had to use only one for all the frames. Don't know how to use both of them s
void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan)
{
HAL_CAN_GetRxMessage(&hcan1, CAN_RX_FIFO0, &RxHeader, RxFrame);
{
switch(RxHeader.StdId)
{
case 0x586:
BatteryChargeCurrent_rcv(RxFrame, &rx_BCC); //Receive frame
BatteryChargeCurrent_memHandler(rx_BCC, &h_BCC); //handle memory
BCCFlag++;
break;
case 0x591:
BatteryCurrentLimit_rcv(RxFrame, &rx_BCL); //Receive frame
BatteryCurrentLimit_memHandler(rx_BCL, h_BCL); //handle memory
BCLFlag++;
break;
case 0x587:
BatteryStatusCharge_rcv(RxFrame, &rx_BSC); //Receive frame
BatteryStatusCharge_memHandler(rx_BSC, h_BSC); //handle memory
BSCFlag++;
break;
case 0x580:
BatteryStatusGeneral_rcv(RxFrame, &rx_BSG); //Receive frame
BatteryStatusGeneral_memHandler(rx_BSG, h_BSG); //handle memory
BSGFlag++;
break;
case 0x59f:
BatteryVehicleHandling_rcv(RxFrame, &rx_BVH); //Receive frame
BatteryVehicleHandling_memHandler(rx_BVH, h_BVH); //handle memory
BVHFlag++;
break;
case 0x24:
EPIC_PMZ_A_rcv(RxFrame, &rx_pmzA); //Receive frame
EPIC_PMZ_A_memHandler(rx_pmzA, h_PMZ_A); //handle memory
break;
case 0x50:
EPIC_PMZ_C_rcv(RxFrame, &rx_pmzC); //Receive frame
EPIC_PMZ_C_memHandler(rx_pmzC, h_PMZ_C); //handle memory
break;
case 0x5A:
EPIC_PMZ_E_rcv(RxFrame, &rx_pmzE); //Receive frame
EPIC_PMZ_E_memHandler(rx_pmzE, h_PMZ_E); //handle memory
break;
case 0x5E:
EPIC_PMZ_G_rcv(RxFrame, &rx_pmzG); //Receive frame
EPIC_PMZ_G_memHandler(rx_pmzG, h_PMZ_G); //handle memory
break;
case 0x60:
EPIC_PMZ_H_rcv(RxFrame, &rx_pmzH); //Receive frame
EPIC_PMZ_H_memHandler(rx_pmzH, h_PMZ_H); //handle memory
break;
case 0x4e2:
EPIC_PMZ_I_rcv(RxFrame, &rx_pmzI); //Receive frame
EPIC_PMZ_I_memHandler(rx_pmzI, &h_PMZ_I); //handle memory
break;
case 0x621:
HMI_DATA1_rcv(RxFrame, &rx_cluster); //Receive frame
HMI_DATA1_memHandler(rx_cluster, h_HMI); //handle memory
break;
case 0x719:
UDS_DIAG_rcv(RxFrame);
UDSFlag ++;
break;
case 0x700:
DCDC700_rcv(RxFrame, &rx_dcdc700); //Receive frame
DCDC700_memHandler(rx_dcdc700, DCDC_700); //handle memory
break;
case 0x703:
DCDC703_rcv(RxFrame, &rx_dcdc703); //Receive frame
break;
default:
sprintf(msg, "Unknown ID in FIFO 1\r\n");
HAL_UART_Transmit(&huart2, (uint8_t*)msg, strlen(msg), HAL_MAX_DELAY);
break;
}
}
}
imultaneously. Then i used only one to receive the frames and it works.
2024-05-21 06:52 AM
Hello,
You can use them both simultaneously. According to the code source you shared at the beginning I don't see an issue.
For each FIFO you can set a filter config, so you will receive the matching message on that FIFO.
Maybe you didn't explain or provide more details of what you intended to do...