Yes, I have. Also Check out @thanos and @Franz_Schmidt posts, as well as mine on this board.
10A continuous with good cooling.
CANBus is unfortunately one of the harder protocols due to its decentralized nature and need for specialized hardware for the physical layer, and also you need to take care of the low level addressing in your data link layer, not like most point-to-point or 7 layer protocols where you know there is only one device on the end of the line or you know how to address it and the rest is handled by the other 6 layers. You are talking directly to the wire. Things get really complex when you have multiple devices talking on the same two-wire line at the same time and you need to handle this chatter in your code by filtering device IDs, priorities and error frames, etc. Best to use specialized hardware and deal only with clean end frames.
@Jason_Kirsons I have a few problems with your library. First was STD::Vector function which is not supported directly by STM32, but I have found an Arduino library to solve those errors. I found an issue converting int and int_32_t with the byte to int function. I just changed the data type to an int.
The last issue I’m currently running into is the override functions causing an error
'void CANCommander::print(float)' marked 'override', but does not override
member function declared with 'override' does not override a base class member
What is the use of the override? can this be removed? I have no errors when removed.
Could anyone please help why I may be getting these errors when compiling. I’m using @Owen_Williams SimpleCAN Library with the examples moved into src where main is located. I’m using PlatformIO with STM32F405 generic. I have no errors or linking errors in the code itself. If I go to definition or declaration it links to the correct STM32 Hal Files. Such as stm32f4xx_hal_can.h and stm32f4xx_hal_can.h.
I have also tried the hal_conf_extra.h put into the library src and called in SimpleCAN.h the contents is:
I did read that CAN HAL is not enabled by default and this is the method to enable it. I have checked and it’s being called correctly and the CAN HAL no longer has the text greyed out. These are the compile errors I’m getting
Compiling .pio\build\genericSTM32F405RG\src\main.cpp.o
Compiling .pio\build\genericSTM32F405RG\lib2ff\SimpleCAN\SimpleCAN.cpp.o
Linking .pio\build\genericSTM32F405RG\firmware.elf
c:/users/matthew/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-
eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe:
pio/build/genericSTM32F405RG/lib2ff/libSimpleCAN.a(SimpleCAN.cpp.o): in function `
CAN1_RX0_IRQHandler':
SimpleCAN.cpp:(.text.CAN1_RX0_IRQHandler+0x4): undefined reference to `
HAL_CAN_IRQHandler'
c:/users/matthew/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-
eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: .
pio/build/genericSTM32F405RG/lib2ff/libSimpleCAN.a(SimpleCAN.cpp.o): in function `
SimpleCAN::init(int, int, CanSpeed, CanMode)':
SimpleCAN.cpp:(.text._ZN9SimpleCAN4initEii8CanSpeed7CanMode+0x84): undefined reference to ` HAL_CAN_Init'
c:/users/matthew/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-
eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: .
pio/build/genericSTM32F405RG/lib2ff/libSimpleCAN.a(SimpleCAN.cpp.o): in function `
SimpleCAN::begin()':
SimpleCAN.cpp:(.text._ZN9SimpleCAN5beginEv+0x4): undefined reference to `HAL_CAN_Start'
c:/users/matthew/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-
eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: .
pio/build/genericSTM32F405RG/lib2ff/libSimpleCAN.a(SimpleCAN.cpp.o): in function `
SimpleCAN::filter(CAN_FilterTypeDef*)':
SimpleCAN.cpp:(.text._ZN9SimpleCAN6filterEP17CAN_FilterTypeDef+0x4): undefined reference to ` HAL_CAN_ConfigFilter'
c:/users/matthew/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-
eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: .
pio/build/genericSTM32F405RG/lib2ff/libSimpleCAN.a(SimpleCAN.cpp.o): in function `
SimpleCAN::transmit(can_message_t*)':
SimpleCAN.cpp:(.text._ZN9SimpleCAN8transmitEP13can_message_t+0x1e): undefined reference
to `HAL_CAN_AddTxMessage'
c:/users/matthew/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-
eabi/9.2.1/../../../../arm-none-eabi/bin/ld.exe: .
pio/build/genericSTM32F405RG/lib2ff/libSimpleCAN.a(SimpleCAN.cpp.o): in function `
SimpleCAN::subscribe(std::function<void (can_message_t*)>)':
SimpleCAN.cpp:(.text._ZN9SimpleCAN9subscribeESt8functionIFvP13can_message_tEE+0x56):
undefined reference to `HAL_CAN_ActivateNotification'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\genericSTM32F405RG\firmware.elf] Error 1
I have tried google without much success and don’t know what to try now
Thanks
Hi, I debug a single Hoverboard motor according to your config and everything is normal, Use two motor at the same time, set the speed one positive and on negative, motor lost control, but speed is the same as that of positive and negative. Works very good, Can you help with the test, detialed link to the problem below: https://community.simplefoc.com/t/stm32-simplefoc-powershield-driver-lost-control-problem/1102/7
Thank you @Owen_Williams and @erwin74 for the work in putting the library together, this is great.
I hit the same problem, but with G431, based on the initial post. Nothing I did made it link successfully.
Apparently the HAL CAN in the latest libraries is disabled by default and I could not enable it no matter what combinations and where I put the hal enable directive.
I am using the Nucleo-32 G431 board.
Any help would be highly appreciated. Could this be due to the latest STM32 library reshuffle?
Hi @Valentine I have got the CAN working on STM32F405 via Arduino/PlatformIO. To enable can you use the build flags in the ini file. Here is a link to my github with a working example. Note the code is messy and needs to be cleaned up, but it does work on the STM32F405 so hopefully it helps you getting it to work.
Thank you. I am using Arduino IDE with the G431 code. The F405 is different, you are using the
stm32f4xx_hal_fdcan.h
and I am using
stm32g4xx_hal_fdcan.h
I tried everything, including adding -DHAL_CAN_MODULE_ENABLED to the project build_opt.h and no success (that -DHAL missing space is on purpose, some weird Arduino IDE thing).
I am sure it’s an environmental problem but I can’t quite hit the target.
If you have any other suggestions it would be great.
Let’s see if anyone else provides any input on this.
Thank you, I just want to add as a clarification, I am looking into the STM32 HAL solution for my education, since CAN Bus is a really messy protocol, not as bad as USB (which is scary bad), but asymptotic as far as time/effort is concerned. I have solved the problem the Gordian way, where I developed my own hardware module (a very tiny PCB using mcp2515 / d230) which uses SPI and completely insulates you both programmatically and galvanically from the CAN horror show and can be used in any schematics regardless of the MCU. Thank you for your help, and let’s see if anyone else has any further feedback on the HAL CAN enable. I am very curious.
Hi, please be aware that FDCAN (CAN FD) is not equal to CAN (classic): CAN FD - Wikipedia. @Matt303 STM32F405 doesn’t support CAN FD (only classic CAN), therefore you can not use the library for FDCAN. As far as I remember Owen_Williams uses a standard Arduino lib for classic CAN (including STM32F40x family). @Valentine the file stm32g4xx_hal_conf.h contains all defines to enable modules (should be there in Arduino also - somewhere). The required module switch is #define HAL_FDCAN_MODULE_ENABLED not HAL_CAN_MODULE_ENABLED. I hope that helps.
thank you. yes however fdcan is fully backwards compatible with can / bacan which was my interest, i want to mix the two, i mean my solution needs g431 and f103 and f042 working together using g431 fdcan in backwards bacan compatible mode.
as far as the flags, you may have a good point i may not have paid attention and copied the can enable instead of the fdcan i am afk but will check in a few hours and if i fat fingered the enable switch that may well deserve me an ass kicking. stay tuned and thank you for pointing this out.
I’m pretty sure the stm32f4xx_hal_fdcan.h library has been updated to have backward compatibility. I noticed you can define and enable classic CAN or something when I was digging through the STM32duino stuff. I got the can working with these defined in my platformio.ini