CAN Bus Library for STM32F103

Can someone help me port this library?
Phono
Posts: 110
Joined: Tue May 05, 2015 6:08 am
Location: Ermont, France

Re: CAN Bus Library for STM32F103

Post by Phono » Thu Nov 29, 2018 7:45 am

I actually updated the repository today to include this change. You will find it at
https://github.com/Phonog

User avatar
Vicolaships
Posts: 22
Joined: Sun Apr 01, 2018 2:36 pm

Re: CAN Bus Library for STM32F103

Post by Vicolaships » Sat Feb 02, 2019 8:28 pm

Hi there!
I would like to start a project with 25 devices (STM32 Blue Pills) communicating through a CAN bus.
I need a CAN bus because I have pretty long cable distances (~ 2 meters) and SPI / I2C are very hard to get working in these conditions.

- Do I need external hardware or can I use the PB8/PB9 and PA11/PA12 pins of the Blue-Pill ? (which one should I use ?)
- What library should I use ? Raw CAN is fine (I don't need CANopen for example)
- What is the state of this library ? Is there some missing functionality ?

I've read a little bit but I'm confused at what software is available and before starting anything I'd like to have more information :)
Thank you for you insights!
Blue-pill | Kubuntu 18.04 | Arduino 1.8.5

User avatar
RogerClark
Posts: 8416
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: CAN Bus Library for STM32F103

Post by RogerClark » Sun Feb 03, 2019 2:15 am

The LibMaple core does not have support for CAN but there is a PR for it, which you could try

I don't know if ST's official core has high level support for CAN, you'd need to PM @fpiSTM and ask

You can always directly access the CAN hardware, but the problem is that its shared with USB, and by default the LibMaple core has USB support enabled unless you upload via hardware Serial

scoace
Posts: 8
Joined: Sat Jan 23, 2016 6:50 am

Re: CAN Bus Library for STM32F103

Post by scoace » Sun Feb 03, 2019 11:26 am

The repository for can support is the link above your post. Works well.

User avatar
Vicolaships
Posts: 22
Joined: Sun Apr 01, 2018 2:36 pm

Re: CAN Bus Library for STM32F103

Post by Vicolaships » Mon Feb 04, 2019 1:02 pm

Ok for the software side.

So I only need a CAN transceiver and the Blue Pill has the CAN controller (used through the HardwareCAN library) within the STM32?

I will do a complete tutorial (wiring + code) on how to communicate between 2 STM32 through a CAN bus when I get the MCP2551 chips and I get everything working.
Blue-pill | Kubuntu 18.04 | Arduino 1.8.5

RogerL
Posts: 30
Joined: Wed Jul 08, 2015 12:54 pm
Location: England

Re: CAN Bus Library for STM32F103

Post by RogerL » Mon Feb 04, 2019 3:53 pm

Vicolaships wrote:
Mon Feb 04, 2019 1:02 pm
I will do a complete tutorial (wiring + code) on how to communicate between 2 STM32 through a CAN bus when I get the MCP2551 chips and I get everything working.
I am planning to do a CAN bus project later in the year, so am looking forward to your tutorial. I have ordered some MCP2551 chips.

stevestrong
Posts: 3053
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany
Contact:

Re: CAN Bus Library for STM32F103

Post by stevestrong » Thu Feb 07, 2019 10:02 am

I just received my 3 modules with MCP2515 +TJA1050, ordered from here: https://www.aliexpress.com/item/MCP2515 ... 72090.html
Now I have to find a project for them 8-)

User avatar
Vicolaships
Posts: 22
Joined: Sun Apr 01, 2018 2:36 pm

Re: CAN Bus Library for STM32F103

Post by Vicolaships » Thu Feb 07, 2019 9:48 pm

stevestrong wrote:
Thu Feb 07, 2019 10:02 am
I just received my 3 modules with MCP2515 +TJA1050, ordered from here: https://www.aliexpress.com/item/MCP2515 ... 72090.html
Now I have to find a project for them 8-)
Cool!

Why did you order such a module (CAN controller and CAN transceiver) if the Blue-Pill (and other STM32s) already have the CAN controller?
Why not order a TJA1050 or MCP2551 directly?
Blue-pill | Kubuntu 18.04 | Arduino 1.8.5

stevestrong
Posts: 3053
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany
Contact:

Re: CAN Bus Library for STM32F103

Post by stevestrong » Fri Feb 08, 2019 8:51 am

Simply because I use the USB serial, so CAN is then unavailable.
And the price for a transceiver alone is not much lower than a complete module, so why to bother with native CAN software?
Nevertheless, I still appreciate the effort to bring CAN to work on bp, just that I find much simpler to use a lib for MCP2515.

User avatar
Vicolaships
Posts: 22
Joined: Sun Apr 01, 2018 2:36 pm

Re: CAN Bus Library for STM32F103

Post by Vicolaships » Sat Feb 23, 2019 7:14 pm

I changed my mind and I will be using libopencm3 for my CAN project:
http://libopencm3.org/docs/latest/stm32 ... fines.html
Blue-pill | Kubuntu 18.04 | Arduino 1.8.5

Post Reply