I am designing a CAN Bus with two STM32F4 Discovery boards. I use transceivers SN65HVD234 from Texas Instruments. I configured the Discovery with CubeMX and used CubeIDE. I am using the HAL library.
I use the User button to fire an EXTI interrupt, that calls HAL_CAN_AddTxMessage()
and writes on the bus.
Transmitting data works, but not receiving. Only receiving in loopback mode works for a board that self-transmits.
The hardware is working very well (confirmed with scope ) and I saw various people having the same problem on other boards, like in this discussion. As I didn't really understand the solution, here is the configuration of my filter :
CAN_FilterTypeDef sFilterConfig;
/*## Configure the CAN Filter ###########################################*/
sFilterConfig.FilterBank = 1; // config seen in [STM32F4 ref manual][2] p1089
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_RX_FIFO0;
sFilterConfig.FilterActivation = ENABLE;
sFilterConfig.SlaveStartFilterBank = 2;
if (HAL_CAN_ConfigFilter(&hcan1, &sFilterConfig) != HAL_OK)
{
/* Filter configuration Error */
Error_Handler();
}
I tried to apply a config seen in the STM32F4 ref manual p1089, but I can't see any way to configure the filter number...
What did I do wrong? I think it could help other people because my design is very classic, using one CAN in normal mode.