# STM32 CAN bus Rx interrupt only triggers in loopback mode

I'm designing the CAN interface for a STM32F042C4T6 to be able to receive and send messages. I've tested my code and everything seems to work perfectly fine in loopback mode. However, when I hook up two STM32's together (with CAN transceivers on both ends as middle men) with one of them transmitting and the other receiving, the STM32 that's supposed to be receiving never enters the receive interrupt. I am sure that the correct CAN message is being sent using my Digilent Analog Discovery board that is able to receive digital CAN, and I probed the CAN Rx pin on the STM32 that is receiving and the message is correct. When I saw this, I thought there might be something wrong with my GPIO initialization code, but it looks like it should work fine. This is it :

//GPIO setup for CAN Tx and Rx
RCC->AHBENR |= RCC_AHBENR_GPIOBEN; //Enable the GPIOB clock
GPIOB->AFR[1] |= (0b0100 << GPIO_AFRH_AFSEL8_Pos) | (0b0100 << GPIO_AFRH_AFSEL9_Pos); //Set PB8 and PB9 to AF4 for CAN
GPIOB->OTYPER &= ~(GPIO_OTYPER_OT_8 | GPIO_OTYPER_OT_9); //Set PB8 and PB9 to push pull
GPIOB->OSPEEDR |= (0b01 << GPIO_OSPEEDR_OSPEEDR8_Pos) | (0b01 << GPIO_OSPEEDR_OSPEEDR9_Pos); //Set PB8 and PB9 to medium speed
GPIOB->MODER |= (0b10 << GPIO_MODER_MODER8_Pos) | (0b10 << GPIO_MODER_MODER9_Pos); //Set PB8 and PB9 to alternate function mode


Another thing that I think might be wrong is that the CAN transceiver outputs 5V digital signals and this is a 3.3V microcontroller, STM32F042C4T6, but I checked, and it is stated in the documentation that these pins are 5V tolerant I/O, which means it should be fine right?

Another thing that I think is very unlikely to be wrong, but still a possibility because I can't really think of anything else is that maybe one the STM32s that is transmitting is sending data out at possibly 1 kHz different than the other STM32 that is receiving, and the CAN message is interpreted incorrectly. However, the bit timing register for both MCU's is the exact same so this is also unlikely.

Does anyone have any ideas as what I could be doing wrong here? If you need for me to post any code I would be glad too, as this is quite important.