Hi,
I working to get both USB and CAN working together on a STM32F103 (Leaflabs Maple).
I have the USB Shell example (ChibiOS_2.6.3\testhal\STM32F1xx\USB_CDC) working nicely,
and I would like to start adding the CAN interface to that example.
However, if I enable both CAN and USB I get the following compile errors :
$ make all
Compiling main.c
Linking build/MoxiUSB.elf
build/obj/usb_lld.o: In function `usb_pm_alloc':
C:\ChibiStudio\workspace\MoxiUSB/../../chibios/os/hal/platforms/STM32/USBv1/usb_lld.c:276: multiple definition of `Vector8C'
build/obj/can_lld.o:C:\ChibiStudio\workspace\MoxiUSB/../../chibios/os/hal/platforms/STM32/can_lld.c:248: first defined here
build/obj/usb_lld.o: In function `Vector90':
C:\ChibiStudio\workspace\MoxiUSB/../../chibios/os/hal/platforms/STM32/USBv1/usb_lld.c:291: multiple definition of `Vector90'
build/obj/can_lld.o:C:\ChibiStudio\workspace\MoxiUSB/../../chibios/os/hal/platforms/STM32/can_lld.c:262: first defined here
collect2.exe: error: ld returned 1 exit status
../../chibios/os/ports/GCC/ARMCMx/rules.mk:181: recipe for target `build/MoxiUSB.elf' failed
make: *** [build/MoxiUSB.elf] Error 1
I imagine that I need to tell the HAL to move the CAN to the alternate pins in the configuration files -
Could someone please point me to an example for that?
I'm sure it's likely something simple that I'm missing...
thanks,
Tom
STM32F103 (Maple) USB and CAN together?
Moderators: barthess, RoccoMarco
- Giovanni
- Site Admin
- Posts: 14704
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1146 times
- Been thanked: 960 times
Re: STM32F103 (Maple) USB and CAN together?
Hi,
USB and CAN together is not possible on the STM32F1, it is an HW limitation. USB and CAN share IRQ, pins and also an internal RAM area.
Giovanni
USB and CAN together is not possible on the STM32F1, it is an HW limitation. USB and CAN share IRQ, pins and also an internal RAM area.
Giovanni
Re: STM32F103 (Maple) USB and CAN together?
Giovanni,
Thank you for the fast response and the explanation.
(I was beginning to think that was the case...)
I'm really enjoying working with ChibiOS - thank you for all your excellent work!
I've been programming for over thirty years, and your code is some of the cleanest
and most readable that I have had the pleasure to work with.
cheers,
Tom
Thank you for the fast response and the explanation.
(I was beginning to think that was the case...)
I'm really enjoying working with ChibiOS - thank you for all your excellent work!
I've been programming for over thirty years, and your code is some of the cleanest
and most readable that I have had the pleasure to work with.
cheers,
Tom
- Giovanni
- Site Admin
- Posts: 14704
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1146 times
- Been thanked: 960 times
Re: STM32F103 (Maple) USB and CAN together?
Hi,
I am glad you like ChibiOS
Note that newer STM32 devices do not have that limitation, for example, the STM32F30x is pretty much a superset of the F1 using updated peripherals.
Giovanni
I am glad you like ChibiOS

Note that newer STM32 devices do not have that limitation, for example, the STM32F30x is pretty much a superset of the F1 using updated peripherals.
Giovanni
-
- Posts: 4
- Joined: Tue Oct 28, 2014 7:40 pm
Re: STM32F103 (Maple) USB and CAN together?
Hi,
I came across this topic as I was also trying to add both drivers (CAN & USB) to a single project:
However, while I do understand USB and CAN cannot be used simultaneously on STM32F103, it is possible to use one of them at a given time (e.g. enable USB and disable CAN, or enable CAN and disable USB), which would require to write a shared IRQ handler and dispatch the IRQ to the currently active peripherial. Is is possible to implement such function in "mainline" ChibiOS or is it unlikely to be useful? I will probably need to implement something like that anyway, because I need to use CAN & USB + STM32F103 in my project, but I'm not sure how to implement this in a clean and nice way so that it could be contributed upstream.
I came across this topic as I was also trying to add both drivers (CAN & USB) to a single project:
Code: Select all
Symbol Vector90 multiply defined (by usb_lld.o and can_lld.o).
However, while I do understand USB and CAN cannot be used simultaneously on STM32F103, it is possible to use one of them at a given time (e.g. enable USB and disable CAN, or enable CAN and disable USB), which would require to write a shared IRQ handler and dispatch the IRQ to the currently active peripherial. Is is possible to implement such function in "mainline" ChibiOS or is it unlikely to be useful? I will probably need to implement something like that anyway, because I need to use CAN & USB + STM32F103 in my project, but I'm not sure how to implement this in a clean and nice way so that it could be contributed upstream.
- Giovanni
- Site Admin
- Posts: 14704
- Joined: Wed May 27, 2009 8:48 am
- Location: Salerno, Italy
- Has thanked: 1146 times
- Been thanked: 960 times
Re: STM32F103 (Maple) USB and CAN together?
Hi,
There is also a pin conflict so you can't use USB and CAN on the same board.
Giovanni
There is also a pin conflict so you can't use USB and CAN on the same board.
Giovanni
-
- Posts: 4
- Joined: Tue Oct 28, 2014 7:40 pm
Re: STM32F103 (Maple) USB and CAN together?
Giovanni wrote:Hi,
There is also a pin conflict so you can't use USB and CAN on the same board.
Giovanni
No, there's no pin conflict as CAN TX/RX ports are remappable to PORTB pins. So the only trouble is the ISR, I tested it with STM32CUBEMX generated code and USB can be used when CAN is disabled and vice versa.
Thanks
Who is online
Users browsing this forum: No registered users and 120 guests