cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4xx Rework of HAL CAN driver: examples?

Stefan Meyre
Associate III
Posted on February 01, 2018 at 21:39

Hello!

The HAL CAN driver for the STM32F4 got reworked lately (december 2017). I try to port my code from the old to the new drivers (compatibility break). There is a brief driver description in the update history but it would be also very helpful to get some example code to speed up porting ;-). I did look up the Cube STM32F4 sample codes but it seems all the CAN samples got deleted (not yet developed?).... Also the HAL description is still version 5 and the new API is not yet worked in. Correct, or did I miss anything?

Cheers, Stefan

16 REPLIES 16
Levs Levs
Associate
Posted on July 05, 2018 at 19:20

Hello guys,

 will be update this CAN driver also on the STM32F1 firmware package?

Best regards,

Levs

DTerr
Associate

Not sure about the STM32F1 but I have heard that STM32F0 is due the 17th week of 2019.

Eich
Associate III

Hi !

One additional topic...

Filter configuration also changed a bit, what is the replacement for the "FilterNumber" ? And how can I change the interrupt priority. Could that be still done by HAL_NVIC_SetPriority(CAN2_RX0_IRQn...)?

Regards,

Dirk

AErns
Associate

Hello Szymon.

I'm struggling to find a very simple and up to date can example, just to see some activity on the Tx pin.

You are talking about a  customers presentation just above, but what do you mean by "Please find it attached"? - I can't see any attachments anywhere.

Regards Allan

JSzuc
Associate II

Hi Szymon!

I try the example on an stm32f103c8t6 and its working fine, but I cant change the filter config to "_IDLIST", Its simply not work anymore in any combination of the mask and id… May be I missed something...

Regards.

J.

Hi szja681.5541402147734006E12,

I began recently with Microcontroller and STM32 and I stumbled over the same issue.

If you are using a standard-ID ( CAN_TxHeaderTypeDef TxHeader; TxHeader.IDE = CAN_ID_STD;)

and Filterscale 32Bit (sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;)

you have to shift FilterIDHigh and FilterMaskIdHigh by 5 Bits to the left.

E.g.

sFilterConfig.FilterIdHigh = 0x0123<<5; 
sFilterConfig.FilterMaskIdHigh = 0x0123<<5;

This is IMO due to the register in the Tx Mailbox.

Here is picture from the STM32F103 Reference Manual .

As you can see the Std-Id is from [31:21].

0690X000009YEi6QAG.png

If you don't shift the Filter ID the comparison will fail.

Because the STD-ID is left justified in the comparing Mailbox.

Here is a pic from the register Organisation.

Mapping is your Mailbox register.0690X000009YEoEQAW.pngI hope this will help someone.

Pictures are taken from the reference manual and are not my property.

Greetings

Rene

MarcV
Associate II

Not sure if anyone is still looking for examples of the new HAL CAN driver like I was just this week. The in my opinion most useful yet simple example can be found here:

https://github.com/timsonater/stm32-CAN-bus-example-HAL-API