cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F207 cubeMx CAN problem

Bla¸ Kvas
Associate
Posted on August 25, 2017 at 09:01

Hi,

I recently started programming on the STM32F207 nucleo board and I ran into a problem.

I used CubeMx to create initialisation code for CAN1 and it doesn't seem to work.

I'm trying to implement CAN with interrupt. Besides the code generated by the cubeMx I initialised the filter in CAN_MspInit function and called the HAL_CAN_Receive_IT(&hcan1, CAN_FIFO0) function in main() before while() loop. 

I looked over the example and I couldn't find an error.

Am I missing something? Does anybody else have this problem.

EDIT:

So I tried it without interrupts.

Transmit function is working fine, but when placed in loopback mode the receive function just times out.

#can #cubemx #stm32f2
1 REPLY 1
Ed Maynard
Associate II
Posted on September 14, 2017 at 17:44

Don't give up! The CAN functionality can be a little tricky I have found on my STM32F413 application. You shouldn't have to call CAN_MspINIT - the mx_CANx_Init() function in main.c calls it. The reason that you are timing out (without the source, YMMV) is that loopback mode does not generate the ACK at the end of the CAN frame that is needed to trigger the interrupt. You need to have another CAN MAC on the bus to generate the ACK if you want the loopback receive to interrupt. Something you could try is to watch the RQCPx flags on the transmit mailbox and generate a software triggered interrupt callback?