cancel
Showing results for 
Search instead for 
Did you mean: 

Anyone using an STM32F4xx with CAN interface. I need to use this in a Receive interrupt mode. I see data on the RX input, but no interrupts.

LBarn.1
Associate II
 
1 ACCEPTED SOLUTION

Accepted Solutions
ACaru.1
Associate II

Yes. I am doing this with dual CAN interfaces using the STM32F417, on the STM324xG Eval board, RX interrupts working perfectly. CubeMX project file attached. Also, checkout the example project at STM32Cube\Repository\STM32Cube_FW_F4_V1.25.0\Projects\STM324xG_EVAL\Examples\CAN\CAN_Networking. And make sure your clock is good -- CAN is picky about a good clock.

View solution in original post

4 REPLIES 4
ACaru.1
Associate II

Yes. I am doing this with dual CAN interfaces using the STM32F417, on the STM324xG Eval board, RX interrupts working perfectly. CubeMX project file attached. Also, checkout the example project at STM32Cube\Repository\STM32Cube_FW_F4_V1.25.0\Projects\STM324xG_EVAL\Examples\CAN\CAN_Networking. And make sure your clock is good -- CAN is picky about a good clock.

LBarn.1
Associate II

Thanks for your response. My project is an upgrade from an STR911 to the STM32. The spec defines the clock as 250 KHz. How do set the clock to get that freq. The STR911 was straight forward.

Yeah, I found this a little confusing too, and this is an area where CubeMX could definitely be improved to help make this easier. The CubeMX project file attached configured both CAN1 and CAN2 for 1Mbps, based on 42MHz peripheral clock. The prescaler of 2 gives a 47.619ns time quantum. The bit period is then 47.619 * (bit segment 1 + bit segment 2 + 1) = 47.619ns * (12 + 8 + 1) = 1us, or 1Mbps. For a 250Kbps bus you can just change the prescaler to 8.

Life would certainly be easier if CubeMX would let you choose from a list of standard bus speeds like 250, 500, 1M, and then calculate the prescaler and bit segment lengths automatically based on the peripheral clock frequency.

LBarn.1
Associate II

Thanks for your help, it all works. The trick was getting the clock just right and it all started to work. It's different than the CAN in the old STR911.