10 years, 1 month ago.


Hi, Is CAN Bus implemented yet on the F103RB Nucleo board? I have tried CAN can1(PA11,PA12); and CAN can1(PB8,PB9); but i cant get it to compile. Regards

Question relating to:

Affordable and flexible platform to ease prototyping using a STM32F103RBT6 microcontroller.

Hi, got (think) same problem: "Error: Identifier "CAN" is undefined" while try to compile a CAN example. Is there a externakl CAN transceiver needed and where the CAN RX/TX Pins are on the Nucleo F103RB (maybe CN3?) ? The "More Information" is a dead end: http://www.st.com/stm32nucleo/ => Page Not Found - 404 Server Error


posted by Lutz Mahle 27 Feb 2014

Hi Lutz,

I am guessing they have not implemented CAN yet. I hope they do because I purchased 2 x f103 boards to use CAN. Yes, it will need an external transceiver when ST or MBED add the CAN function. I do not know a lot about the mbed library but if you look in the target directory for each platform, there is a file called 'device.h'. If you look, for instance, in the device.h for the target LPC1768 (the original mbed) you see the statement '#define DEVICE_CAN 1' which tells the library that this processor supports CAN Bus. If you look in the device.h for the F103, the statement #DEFINE DEVICE_CAN does not even exist. My guess is that they have done the minimum just to get all the Nucleo boards released. I think a lot of the engineers will be at Embedded World Expo this week so hopefully we will get some answers soon when they are back :). Regards Chris

posted by Chris Smith 27 Feb 2014

Mbed library info here http://mbed.org/users/mbed_official/code/mbed/

posted by Chris Smith 27 Feb 2014

4 Answers

8 years, 8 months ago.

Any update on this? I am currently trying to use the CAN bus on a Nucleo F072RB. I am very new to coding and have not been able to find any information to get this working. Someone recently created a CANnucleo program however it does not work with the Nucleo F072RB. It seems like there is something simple missing but I don't know enough to debug it.

Hi Paul, nothing as far as i am aware. I am avoiding using the ST parts at the moment because the mbed CAN layer is not implemented and I'm sure there are many people in the same boat. I'm sure ST have their reasons for not adding the mbed CAN layer but in the meantime our company has 4 seperate products using NXP LPC1768 devices because it was easier for me to prototype the CAN functions.

Regards Chris

posted by Chris Smith 05 Aug 2015

Thanks for your response Chris, i guess I am not the only one having issues then.

posted by Paul Wright 05 Aug 2015

Hi, In case someone is looking for a CAN library for the NUCLEO-F103RB boards, there is one published here.

posted by Zoltan Hudak 05 Aug 2015

Zoltan, I am trying to see why your CANnucleo does not work on the Nucleo F072RB all errors seem to lead to the fact that the "class CAN" is not set up correctly on line 133 of CAN.h do you have the class setup somewhere else? Any idea how to fix it?

posted by Paul Wright 05 Aug 2015

Hi Paul. This error is reported by the compiler because there is already one CAN class defined by the mbed library. But even if one circumvents it, for instance by using a different class name, it is just the tip of the iceberg. The implementation of Hardware Application Layer (HAL) for the STM32F072RB controller is missing (supposed to be specified in can_api.c). Since the architecture of STM32F072RB (Cortex-M0) differs from the STM32F103RB (Cortex-M3) it's impossible to use the same HAL for both controllers.

Regards Zoltan

posted by Zoltan Hudak 05 Aug 2015
5 years, 9 months ago.

'm sure ST have their reasons for not adding the mbed CAN layer but in the meantime our company has 4 seperate products using NXP LPC1768 devices because it was easier for me to prototype the CAN functions. kissmanga

Hi CAN is supported for a long time by STM32... https://github.com/ARMmbed/mbed-os/blob/master/targets/TARGET_STM/can_api.c

posted by Jerome Coutant 12 Jul 2018
7 years, 2 months ago.

I think that mbed is supposed to speedup coding and create projects with better portability, in the can filed for what i see thay are miserably failing for the STM32 were you can only cound on user libraries such as the canucleo or the low level st libraries that for who see in mbed a growing step from arduino is maybe too diffocult.

10 years, 1 month ago.

you can reach the nucleo page on ST web site at http://www.st.com/stm32nucleo without the final /

mbed layer for CAN is not implemented yet but the underlying library does. Look at the TARGET_NUCLEO_F103RB/stm32f10x_can.h in the mbed code (see link from Chris Smith post). plenty of examples are given in ST library for STM32F103 here

Keep in mind you will need a quartz and probably a transceiver to properly use the CAN interface as these are not provided with the nucleo board

Hi Maxime,

Thanks for your reply. I dont know if you work for ST or not but I have to say that. I'm a bit fustrated and a little confused as to why ST make a point of the F103 Nucleo having CAN but did not just do this coding themselves to start with. Surely the whole point of the Nucleo is to introduce ST processors to people and showcase what they can do.

Yes, i am sure that given time i can understand what is needed to write the link layer between the MBED and ST libraires but as a hardware engineer this is not an area that i am very comfortable with and when I saw the nucleo boards with F103 and 'CAN' i just assumed, like a lot of other people probably will, that i could just jump in and start using all the chips functions in the easy mbed way from the start.

Regards Chris

posted by Chris Smith 03 Mar 2014

My finger is pointing squarely at mbed rather than ST on this one Chris. The STMF103RB has two CAN interfaces, and these are well documented, and are supported by ST's libraries. They've done their job. But the mbed libraries lack the same support, despite the fact that mbed's own page describing the F103 Nucleo list CAN as a feature (https://mbed.org/platforms/ST-Nucleo-F103RB/).

The necessary addition to the mbed libraries doesn't even have to use the ST libraries underneath - their peripheral libraries generally do very little, and if I were to write it I'd use direct access to the peripheral control registers. But I'd rather not write it, because that's exactly the kind of thing that using the mbed libraries is supposed to save me from having to do...

posted by Andy Pomfret 04 Mar 2014