Setting Up CAN reader - STM32 Nucleo board

Post Reply
RetroZero
Posts: 731
Joined: Tue Oct 29, 2019 2:48 pm
Location: France
Has thanked: 329 times
Been thanked: 44 times
Contact:

Setting Up CAN reader - STM32 Nucleo board

Post by RetroZero »

After many moocs on CAN protocol setting up, and reading up the well documented Wiki regarding setting up CAN reader with Arduino-Due, I have to ask if there are any solutions to transport the project to a STM32 board.
I downloaded Collin80 Github code, GV-RET library, SavvyCAN
I have a Nucleo board, which seems to not be compatible with available STM CAN library examples (too old?).
So first, I thought I would simply compile in Arduino Due, stipulating I have a STM board - the file would not compile with error messages. Many Utube videos later, I abandoned this method.
I have read that most STM microcontrollers are identicle, so I copied a few CAN loopback examples from a library that was the closest to my board.
After a few attempts, I managed to download and create the project, but error messages have occured when debuggung, that I don't know how to decode.
After 20 Moocs on CAN protocole coding, I continued scrolling around and around to find where I was going wrong with no success.
I have not found a setup using a STM board running Arduino-Due code for the setup.
I know there are solutions now that are plug and play, however I was hoping to stay with the STM setup and understand the process for reading CAN.
I have 2 SN65HVD230 devices connected in a loop via CAN H and CAN L
I have connected them in parralel to TX and RX outputs from my Nucleo Board, along with 3.3v and ground terminals.
I have configured the Pins for correct TX and RX outputs in STMCube (I think)
I,ve read up on baud rates, quanta times, etc, but this is way above my pay-grade.
I thought it would be much simpler and any pointers would be appreciated.
My aim was to help retreive CAN data for reverse engineer gurus, along with setting up a VAG charger eventually....
User avatar
uhi22
Posts: 601
Joined: Mon Mar 14, 2022 3:20 pm
Location: Ingolstadt/Germany
Has thanked: 91 times
Been thanked: 412 times

Re: Setting Up CAN reader - STM32 Nucleo board

Post by uhi22 »

This could be an interesting and helpful project, using a nucleo board (or a cheap bluepill) as GVRET interface for SavvyCAN.
Your hardware setup sounds strange, you really have two transceivers on one controller? Never seen this before. I would start with a normal CAN setup, just one transceiver, and a termination. But testing CAN with just one node is boring, the controller tries to send something, does not get an ACK, and floods the bus with always the same message.
I'm not familiar with stm in the Arduino IDE, used the STM cubeIDE in the early versions of ccs32clara. You could take this as fist step to check the hardware setup.
RetroZero
Posts: 731
Joined: Tue Oct 29, 2019 2:48 pm
Location: France
Has thanked: 329 times
Been thanked: 44 times
Contact:

Re: Setting Up CAN reader - STM32 Nucleo board

Post by RetroZero »

Thanks uhi22, I have reverted to the initial setup as per the Arduino/Wiki/@Gregski setup.
From what I understand.....
I need to setup my Nucleo board and activate the CAN tx and CAN rx pins in Config Setup when creating a new Project.
This part I can do.
Then I am supposed to import the Code from Collin80 as per the Wiki Setup and it will convert if needed?
User avatar
uhi22
Posts: 601
Joined: Mon Mar 14, 2022 3:20 pm
Location: Ingolstadt/Germany
Has thanked: 91 times
Been thanked: 412 times

Re: Setting Up CAN reader - STM32 Nucleo board

Post by uhi22 »

Could you add some links where you found the information you use? Which wiki page? And which IDE do you use, in which version? And which controller is on your nucleo?
RetroZero
Posts: 731
Joined: Tue Oct 29, 2019 2:48 pm
Location: France
Has thanked: 329 times
Been thanked: 44 times
Contact:

Re: Setting Up CAN reader - STM32 Nucleo board

Post by RetroZero »

Thanks, I followed the wiki https://openinverter.org/wiki/CAN_bus_with_Arduino_Due.
I downloaded Collin80 zip files along with Savvy CAN from the links.
I now understand how to activate CAN TX and CAN TX on my STM32NuckeoF338R8 board.
I connected the SN65HVD230 CAN bus transceiver as per the wiki setup.
My problems start here where I'm trying to copy a working setup from Arduino to STM , or is this supposed to be compatible?
royhen99
Posts: 211
Joined: Sun Feb 20, 2022 4:23 am
Location: N. Wiltshire. UK
Has thanked: 16 times
Been thanked: 101 times

Re: Setting Up CAN reader - STM32 Nucleo board

Post by royhen99 »

You can not just change board type and expect it to compile . The STM32 core library does not support can so an external library is needed, ( or write your own ). Even then a lot of changes are needed to get it to work.

Non of the libraries I am familar with support STM32F334.
RetroZero
Posts: 731
Joined: Tue Oct 29, 2019 2:48 pm
Location: France
Has thanked: 329 times
Been thanked: 44 times
Contact:

Re: Setting Up CAN reader - STM32 Nucleo board

Post by RetroZero »

Yes, it seems later DEV boards have examples ready for applications. My board has CAN pinouts and thought it would be an easy fix to convert.
I read that most STM ARM MCU are the same and libraries can be used from one to the other with 'slight' modifications, but I'm no code developer, so might have to go the 'buy off the shelf ' option 😔
User avatar
uhi22
Posts: 601
Joined: Mon Mar 14, 2022 3:20 pm
Location: Ingolstadt/Germany
Has thanked: 91 times
Been thanked: 412 times

Re: Setting Up CAN reader - STM32 Nucleo board

Post by uhi22 »

A bit off-topic, but if you search for a minimal version, that you can make by your own, you could have a look to https://github.com/uhi22/wifican which uses an ESP32s3, and connects via WLAN. In general I would appreciate an STM solution instead, but the ESP solution is better than nothing.
RetroZero
Posts: 731
Joined: Tue Oct 29, 2019 2:48 pm
Location: France
Has thanked: 329 times
Been thanked: 44 times
Contact:

Re: Setting Up CAN reader - STM32 Nucleo board

Post by RetroZero »

If I were to carry out the set-up I found and connected it to a CAN network (contact relay control unit or instrument cluster) should I not be able to read a CAN message at least on the STM board?
https://controllerstech.com/can-protocol-in-stm32/

If this is confirmed, I would have thought porting Arduino code and GV-RET files would be possible...
RetroZero
Posts: 731
Joined: Tue Oct 29, 2019 2:48 pm
Location: France
Has thanked: 329 times
Been thanked: 44 times
Contact:

Re: Setting Up CAN reader - STM32 Nucleo board

Post by RetroZero »

I found a link that allows for STM32 to be used in ArduinoIDE.
I downloaded the ArduinoIDE and STM programmer.
I tried the Blinkexample, but after starting the debug, I get errors

Now I have a basic CAN example from STM Community which I managed to download.
Next step is to test if it is reading anything.
I have bought an ESp32-S3 and checking out @uhi22 and his Wifi CAN example. The plan is to make up a bus on a breadboard, runthe STM32 board and listen to the messages from the ESP32.......
Post Reply