2018-09-06 04:38 AM
I am working on STM32F4-Discovery board with STM32F412ZG. Trying to work CAN communication between MCU and PC with the help of kvaser canking tool(SJW=1, bus speed=125 kbps). I got success in transmitting data to PC successfully and I am getting correct data without any error. But unable to receive data on same can bus. Whenever i send data from PC over CAN, I am not able to get any data in MCU's FIFO mailbox. I have checked CAN_RX and GND pins on DSO and i am getting pulses(data) till connector(CN12) of discovery board. i have checked schematic of discovery board and connection of that connector is directly gone to MCU pin. But still not able to receive data in FIFO mailbox.
I am attaching my code here. Please suggest if i missed anything in order to receive data successfully.
2018-09-06 02:08 PM
did you enable the interrupts?
there are 2 fifos.
__HAL_CAN_ENABLE_IT(&hcan, CAN_IT_FMP1);
__HAL_CAN_ENABLE_IT(&hcan, CAN_IT_FMP0);
2018-09-10 03:57 AM
I got my answer. Actually, filter initialization was a problem. Now, I am able to both transmit and receive the data. Thanks.
2018-09-10 03:59 AM
2018-09-11 11:01 PM
sFilterConfig.FilterNumber=0;//filter 0 will be initialized
sFilterConfig.FilterMode=CAN_FILTERMODE_IDMASK;//Identifier mask mode
// sFilterConfig.FilterMode=CAN_FILTERMODE_IDLIST;//Identifier list mode
sFilterConfig.FilterScale=CAN_FILTERSCALE_32BIT;//One 32-bit filter
sFilterConfig.FilterIdHigh=0x00;//filter identification number - MSBs for a 32-bit configuration
sFilterConfig.FilterIdLow=0x00;//filter identification number - LSBs for a 32-bit configuration
sFilterConfig.FilterMaskIdHigh=0x00;//filter mask number or identification number,according to the mode - MSBs for a 32-bit configuration
sFilterConfig.FilterMaskIdLow=0xFF;//filter mask number or identification number,according to the mode - LSBs for a 32-bit configuration
sFilterConfig.FilterFIFOAssignment=CAN_FIFO0;//FIFO 0 will be assigned to the filter.
sFilterConfig.FilterActivation=ENABLE;//Enable or disable the filter.
HAL_CAN_ConfigFilter(&hcan1, &sFilterConfig);