cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F two independent CAN BUS

K_K
Associate II
Posted on December 12, 2016 at 11:50

I am new in CAN bus protocol and wanted to use two CAN channels in the STM32F as I have to receive/transmit data from/to the two different CAN bus. As per study I found that there is no master slave concept in CAN protocol but when I look at cubemx, it is configuring CAN1 as a Master and CAN2 as a Slave. In STM32F7, there are two Master CAN and one slave. What does it mean? Is it possible to transmit data using slave (CAN2)?

Please guide.

#can #stm32
8 REPLIES 8
Alan Chambers
Associate II
Posted on December 12, 2016 at 13:00

I have used the bxCAN on a device which had both CAN1 and CAN2. The MCU was STM32F429. The master/slave concept is in the bxCAN peripheral, not CubeMX. I'm not familiar enough with the details of the hardware or the reference manual to really understand the master/slave concept. It was irrelevant to my application or, at least, didn't have any significant impact.

In my case, the buses were completely independent except that the 'slave' would not work unless the 'master' was also initialised and enabled. 

Posted on December 12, 2016 at 13:57

In the F4 CAN1 is a full implementation of hardware and CAN2 is a half implementation, so CAN1 must be functional to use CAN2. Both would communicate on different buses.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
ST Renegade
Senior
Posted on December 12, 2016 at 13:59

If you have two different CAN buses, you can wire them into one and receive the whole communication on one channel if possible/allowed by your design etc. You don't need to have two channels for this (if there are no other constraints).

Regarding the Master/Slave architecture on ST, if you read the reference manual, the CAN1 is called Master, because CAN2 has no direct access to the SRAM memory. Why SRAM? The CAN is implemented that way, that all the filter registers etc. reside in SRAM instead of Flash... That's why they call it Master and Slave. So if using only one CAN, from logical point of view you should start with CAN1.

Hope this helps! Have a nice day,

Renegade

K_K
Associate II
Posted on December 15, 2016 at 10:28

Thanks for sharing your views and experience.

That means I can use both CAN independently and will be able to transmit and receive data from any CAN channel, right?

Only thing is, I have to configure CAN1 to use CAN2.

Also I would like to know if someone noticed any difference in CAN module in STM32F105 and STm32F4/7 series MCU.

Secondly, noticed that device contains extended CAN, Is it possible to configure as a standard CAN? I think it should be possible but unable to find any clear indication in reference manual.

Thanks Again.

Jeroen3
Senior
Posted on December 16, 2016 at 08:15

I don't think there are differences in bxCAN. I've used it in F0, F1 and F4, did not notice major differences. Apart that some chips can't run USB and CAN together due to the same sram block being used as buffer.

I've never used 2.0B, but it seems like bxCAN supports both, simultaneously. Simply by always being in standard mode.

This would explain why you have to left shift the filters if you have a standard ID. 

Maybe someone can verify?

Walid FTITI_O
Senior II
Posted on December 16, 2016 at 10:59

Hi

Khetani.Krunal.002

,

1. CAN1 and CAN2 dependency:

You have to enable also CAN1 clock to work with CAN2.

As mentioned in reference manual RM0090, “Dual CAN�? part ( page 1069) :

'- CAN1: Master bxCAN for managing the communication between a Slave

bxCAN and the 512-byte SRAM memory.

-CAN2: Slave bxCAN, with no direct access to the SRAM memory.'

->Hence when using CAN2 it's obligatory to enable the Clock of CAN1 accordingly.

2. STM32 product/peripheral compatibility:

To check the compatibility between STM32 devices and their peripheral, an in particular case the compatibility about CAN peripheral between STM32F1 and STM32F4, you would refer to following resource:

Application note

http://www.st.com/content/ccc/resource/technical/document/application_note/cd/33/56/56/87/13/46/25/DM000248pdf/files/DM000248pdf/jcr:content/translations/en.DM000248pdf

->Table 4. STM32 peripheral compatibility analysis F1 versus F4 series

IF the response is useful, you would press the correct button

-Walid F-

Posted on May 21, 2018 at 11:41

I'm developing an application with STM32f446 and I need one CAN bus with which I I want to use CAN bootloader in system memory (preprogrammed bootloader via CAN). In STM32F446 the CAN bootloader is implemented in CAN2 that is slave and therefore I have to use only CAN2.

In this case it's necessary to activate also CAN1?
Posted on May 21, 2018 at 14:27

As has been long established the CAN2 is a slave to CAN1, basically you have 1.5 CAN Peripherals that share a lot of logic.

You should enable both CAN1 and CAN2, and use the upper filters.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..