STM32F429 is not receiving the CAN Message

user2870154 picture user2870154 · Dec 5, 2014 · Viewed 12.6k times · Source

I am using STM32F429 Microcontroller and need to implement CAN Bus Communication between CAN2 and PCAN View.I am able to transmit the message from CAN2 but I am not able to receive any message.I am using TJA1041A CAN transreceiver in the microcontroller.The Problem is that during debugging my CAN bus are properly initalized but it doesn't go to the receive command although I have initalized FIFO0.Herewith I am attching the program for further reference.I have used STM32 HAL Cube for programming.

Thanks

Answer

Xerxiz picture Xerxiz · Jan 9, 2015

If CAN2 can send messages, the clock and master-slave configurations between CAN1 (master) and CAN2 (slave) are ok.

If there are receiving issues these should be related to the FIFO config or the acceptance filter config.

You configured the FIFO, but it looks like you did not configure the "CAN2StartBank". CAN1 and CAN2 share also the filter banks and by default the banks are divided in half, so the first half is used for CAN1 and the second half for CAN2.

From the reference manual chapter "CAN Filter Registers":

CAN filter master register (CAN_FMR)

Address offset: 0x200 Reset value: 0x2A1C 0E01 All bits of this

register are set and cleared by software. ... CAN2SB[5:0]: CAN2 start bank These bits are set and cleared by

software. They define the start bank for the CAN2 interface (Slave) in

the range 0 to 27. Note: When CAN2SB[5:0] = 28d, all the filters to

CAN1 can be used. When CAN2SB[5:0] is set to 0,no filters are assigned to CAN1.

You set the

CAN_Filters.BankNumber = 0;

but you should choose a bank from the second half with default settings or change the CAN2StartBank value to 0 if you don't need CAN1.

You also have to make sure, that the Filters an in initialisation mode during filter configuration.

CAN filter master register (CAN_FMR)

Bit 0 FINIT : Filter init mode Initialization mode for filter banks

0: Active filters mode.

1: Initialization mode for the filters

Sadly I have no hardware right now to test this by my self.