cancel
Showing results for 
Search instead for 
Did you mean: 

CAN and USB together?

er2
Associate III
Posted on April 12, 2008 at 09:35

CAN and USB together?

12 REPLIES 12
er2
Associate III
Posted on May 17, 2011 at 12:27

In my project i must use then CAN and USB bus.

The datasheet says that CAN and USB shares a dedicated 512-byte SRAM. For USB the used adresses can be defined with SetBTABLE(BTABLE_ADDRESS). So i know what adresses are used. But which adresses do CAN use? I haven't found any information about this in the datasheet. Can somebody help me?

Erwin

philipp2399
Associate II
Posted on May 17, 2011 at 12:27

Hi Erwin,

I also plan to use CAN and USB together, but it seems to be a real problem. I just tried what happens. CAN pins are remapped to PB8 and PB9, so they don't interfere with USB pins PA11 PA12. As soon as I enable the CAN clock my USB connection brakes down, even if I don't initialize CAN.

When I disable CAN clock, USB works again.

I expect it is possible to switch between the two interfaces but they never work together.

I can't find any information about the behaviour of CAN together with USB. Did you find anything?

Philipp

mvi
Associate II
Posted on May 17, 2011 at 12:27

Hi,

From Datasheet:

''The USB and CAN share a dedicated 512-byte SRAM memory for data transmission and reception, and so they cannot be used concurrently (the shared SRAM is accessed through CAN and USB exclusively). The USB and CAN can be used in the same application but not at the same time.''

-Mad

philipp2399
Associate II
Posted on May 17, 2011 at 12:27

Hi Mad,

That explains everything. Thanx. When I started with the STM32 only the old UM0306 Reference Manual was available, and there this information was missing.

Philipp

16-32micros
Associate III
Posted on May 17, 2011 at 12:27

Hi all,

CAN and USB can not work together as same time because they are sharing the same RAM memory for data transmission. Hope it is more clear now.

By the way, do you need really both CAN and USB on the same design, is it a USB bridge to CAN ?

Cheers,

STOne-32.

er2
Associate III
Posted on May 17, 2011 at 12:27

I have tried a lot of things, but it happens always when i activate the rcc-clock for CAN, USB doesn't work anymore. So, it is not possible to get USB and CAN working together. Let's hope for the next STM32 generation.

philipp2399
Associate II
Posted on May 17, 2011 at 12:27

Hi all,

Why to use USB and CAN together?

We are using CAN as a field bus to integrate our controller in to the cutomers application.

As a service interface we use RS232. But this interface is not available any more on new PCs. So we have to use either USB or Ethernet. Therefore the USB-COM interface is the ideal solution for us - but the field bus is specified by our customer so we need CAN.

We prefer not to use an external USB-CAN bridge because

- we would have to equip every service engineer with such a bridge.

- it changes the CAN-bus traffic of our customer

- we tried various external USB-CAN bridges, and all of them couldn't deal with the heavy bus traffic at 1M/s (although the receive filter was set correctly). They either missed some frames or mixed up the order of received frames.

For the current project I decided to disable CAN communication as soon as USB is connected. This means we can update system parameters but we have no access to our controller when the whole system is in operation.

Is there any chance in future to improve this? If CAN could be operated without the use of 512Bytes SRAM (eg by using DMA instead of FIFO and a reduced number of receive filters?

Philipp

flyer31
Senior
Posted on December 07, 2012 at 08:49

Hi STOne-32,

this is a really strange question, how do you expect to connect CAN devices with PC on STM32F4?

Can you give a hint, whether it possibly will be at least possible with the new STM32F427 or STM32F437 to connect CAN and USB?

(btw for the ''bridge processor'' I would really appreciate very much, if it would be possible to use even both CAN interfaces plus the USB-HS (ULPI). Currently unfortunately CAN2 collides with USB-ULPI pins in the Alternate Function map).

Or do you plan to introduce some special ''connectivity line'' also for STM32F4? The problem is, that I have so much data, I need USB-HS. And if possible I would prefer CAN very much to handle the transfer to the slower peripherals.

Nickname12657_O
Associate III
Posted on December 07, 2012 at 09:46

Hi bil,

If I remember well this discussion, it was not about STM32F4.

Also, I think you misunderstand the subject.

In this discussion we are talking about the possibility to use CAN and USB at the same application running on STM32F10x (x is not 5 nor 7); with these products, user can not use in his application CAN and USB at the same time because they are sharing the same RAM memory for data transmission.

With STM32F105/F107/F2xx/F4xx, this is solved and user can develop an application with USB and CAN communicate with other peripherals at the same time.

For your application, you can use USB HS (ULPI) and CAN1.

Cheers,

STOne-32.