cancel
Showing results for 
Search instead for 
Did you mean: 

CAN Legacy with STM32F042, STM32Cube Version 5.3.0, FW V1.10.

christophkeiner9
Associate III

I wanted to use the CAN Legacy Driver like i did it in my old STM32F103 Project (Same Cube Version. latest Firmware) but i failed.

I copied the Legacy CAN-Module to the Driver Source-Path, the Legacy Include's were already included.

But what should i do now? In the old Project i only enabled the Legacy Driver in the HAL_conf.h, but this Fails with the STM32F042.

What is the way to enable it here, or is there anywhere a good example how to ust Interrupt Receive with the new Driver??

1 ACCEPTED SOLUTION

Accepted Solutions
christophkeiner9
Associate III

​Thank you for your Help!

This is exactly what i did to get it working but i failed.

Meanwhile i changed to the new Structure because there were too many detail changes to make Legacy work, rewriting was really the better Solution.

View solution in original post

10 REPLIES 10
Imen.D
ST Employee

Hello @christophkeiner9​ ,

The Legacy HAL CAN driver is present in the package release in Driver/STM32F0xx_HAL_Driver/Src/Legacy and Driver/STM32F0xx_HAL_Driver/Inc/Legacy folders for software compatibility reasons. Its usage is not recommended as deprecated.

It can however be enabled through switch HAL_CAN_LEGACY_MODULE_ENABLED in stm32f0xx_hal_conf.h file.

Also, check that CAN initialization and configuration are properly done.

Regards,

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
christophkeiner9
Associate III

​Thank you for your Help!

This is exactly what i did to get it working but i failed.

Meanwhile i changed to the new Structure because there were too many detail changes to make Legacy work, rewriting was really the better Solution.

MAesc.1
Associate II

I have the same issu for a F2. In the MCU Package Version 1.8.0 for the STM32F2 it is mentioned, that the old CAN driver is still available. But as you can see in the image, there is no one. And a definition of "HAL_CAN_LEGACY_MODULE_ENABLED" leads to an "Unresolve inclusion error". Is there a workaround? Our customer is running tests for 2 months with the olc CAN API and it is crucial not to repeat these tests with a new CAN API.

0690X00000BxC8TQAV.jpg

christophkeiner9
Associate III

Yes, i know, there are a lot of little things to do to get it run, therefore i would not rely on a new software with so many little manual changes.

I would turn back to the older Cube-Version or use the new CAN Driver and do the testing again.

Karl Yamashita
Lead III

I have a working project on github based off a CANable adapter that uses the STM32F042. I've also made a YouTube tutorial on how to start a STM32CubeIDE project.

https://github.com/karlyamashita/CANable_USB_CAN

https://www.youtube.com/watch?v=oe5JmYYAZy0&t=5s

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.
christophkeiner9
Associate III

​Thank you Karl, very nice Project. Do you use a crystal for clocking on the PCB, i didn't see it?

The whole uC is running with the internal RC at 48mHz. Surprisingly the USB communication works just as well as the CAN controller.

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.
christophkeiner9
Associate III

Hi Karl, yes i see, the oscillator is synchronized to USB Data Stream, therefore it is sufficient accurate also for higher CAN Datarates. I never used the USB-Device but it's an nice feature.

paulcatherall9
Associate II

I'm considering the STM32F042 for a new design with a PCB size constraint, I have always used an external crystal when using CAN.

Is it possible to use this devices internal oscillator ? Anyone had any experience. Max bit rate 125kbs

Thanks