You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@BennehBoy
Yes of course. All STM32 features are available thanks HAL/LL (if user enable the right HAL module).
All stuff which can be done thanks the cube are available. By no support I told about Arduino point of view, there is no dedicated library to support STM32 CAN for this core with specific Arduino API style
Unfortunately the UAVCAN example only works with the STM32Duino version 1.4.
With version 1.8 I get the following errors:
`
sketch\can.c: In function 'MX_CAN_Init':
can.c:12: error: 'CAN_InitTypeDef' {aka 'struct '} has no member named 'SJW'
12 | hcan.Init.SJW = CAN_SJW_1TQ;
| ^
can.c:13: error: 'CAN_InitTypeDef' {aka 'struct '} has no member named 'BS1'
13 | hcan.Init.BS1 = CAN_BS1_1TQ;
| ^
can.c:14: error: 'CAN_InitTypeDef' {aka 'struct '} has no member named 'BS2'
14 | hcan.Init.BS2 = CAN_BS2_1TQ;
| ^
can.c:15: error: 'CAN_InitTypeDef' {aka 'struct '} has no member named 'TTCM'
15 | hcan.Init.TTCM = DISABLE;
| ^
can.c:16: error: 'CAN_InitTypeDef' {aka 'struct '} has no member named 'ABOM'
16 | hcan.Init.ABOM = DISABLE;
| ^
can.c:17: error: 'CAN_InitTypeDef' {aka 'struct '} has no member named 'AWUM'
17 | hcan.Init.AWUM = DISABLE;
| ^
can.c:18: error: 'CAN_InitTypeDef' {aka 'struct '} has no member named 'NART'
18 | hcan.Init.NART = DISABLE;
| ^
can.c:19: error: 'CAN_InitTypeDef' {aka 'struct '} has no member named 'RFLM'
19 | hcan.Init.RFLM = DISABLE;
| ^
can.c:20: error: 'CAN_InitTypeDef' {aka 'struct '} has no member named 'TXFP'
20 | hcan.Init.TXFP = DISABLE;
| ^
exit status 1
'CAN_InitTypeDef' {aka 'struct '} has no member named 'SJW'
`
Is there maybe an easy way to get it running with the current version?
HAL CAN update
Fields of CAN_InitTypeDef structure are reworked:
SJW to SyncJumpWidth, BS1 to TimeSeg1, BS2 to TimeSeg2, TTCM to TimeTriggeredMode, ABOM to AutoBusOff, AWUM to AutoWakeUp, NART to AutoRetransmission (inversed), RFLM to ReceiveFifoLocked and TXFP to TransmitFifoPriority
HAL_CAN_Init() is split into both HAL_CAN_Init() and HAL_CAN_Start() API’s
HAL_CAN_Transmit() is replaced by HAL_CAN_AddTxMessage() to place Tx Request, then HAL_CAN_GetTxMailboxesFreeLevel() for polling until completion.
HAL_CAN_Transmit_IT() is replaced by HAL_CAN_ActivateNotification() to enable transmit IT, then HAL_CAN_AddTxMessage() for place Tx request.
HAL_CAN_Receive() is replaced by HAL_CAN_GetRxFifoFillLevel() for polling until reception, then HAL_CAN_GetRxMessage()
to get Rx message.
HAL_CAN_Receive_IT() is replaced by HAL_CAN_ActivateNotification() to enable receive IT, then HAL_CAN_GetRxMessage()
in the receivecallback to get Rx message
HAL_CAN_Slepp() is renamed as HAL_CAN_RequestSleep()
HAL_CAN_TxCpltCallback() is split into HAL_CAN_TxMailbox0CompleteCallback(), HAL_CAN_TxMailbox1CompleteCallback() and HAL_CAN_TxMailbox2CompleteCallback().
HAL_CAN_RxCpltCallback is split into HAL_CAN_RxFifo0MsgPendingCallback() and HAL_CAN_RxFifo1MsgPendingCallback().
More complete “How to use the new driver” is detailed in the driver header section itself.
It seems there is an HAL_CAN_LEGACY_MODULE_ENABLED which can be enabled to use the legacy one but HAL_CAN_MODULE_ENABLED have to be disabled.
Does anybody know of a library that will work with the HAL_FDCAN_MODULE_ENABLED? @J-f-Jensen library is great but I can't get it to compile for my Nucleo-H743IZ2.
or is there a way to use HAL_CAN_MODULE_ENABLED with the Nucleo-H743IZ2?
Thanks
@shaneyake The library only works for F1 series as far as I know, because that's the only one using AFIO for pin mapping. F4 andvothets have different way to map pins, so that's why it wont compile (as I mentioned above).
any progress on this? would be very useful to have can support...
You can use this library I created. Uses HAL drivers, hadware interrupts and it's easy to use. Should work with every stm32 chip that is supported by stm32duino: https://github.com/pazi88/STM32_CAN
I have been meaning to do some last modifications to that and maybe make a PR for that to be added in stm32core. I have been personally used that with many projects communicating busy vehicle CAN busses and it works great (other ones I have found, have many problems).
e last modifications to that and maybe make a PR for that to be added in stm32core. I have been personally used that with many projects communicating busy vehicle CAan busses and it works great (other ones I have found, have many problems).
Hi @pazi88, do not hesitate to male a PR or you can also share it as an Arduino library.
Wow thanks @pazi88 will test tomorrow! Was previously using MBed but it is failing with high bus loads....
Yes with other libraries available I also had problems with high bus loads, but with this one all seems fine, because both TX and RX side are interrupt based and the packets are gathered to buffers that have configurable size.
e last modifications to that and maybe make a PR for that to be added in stm32core. I have been personally used that with many projects communicating busy vehicle CAan busses and it works great (other ones I have found, have many problems).
Hi @pazi88, do not hesitate to male a PR or you can also share it as an Arduino library.
It works already as Arduino library. But I'll do those additions I have been meaning to do and do a PR then.
There is a working Can instance here, but this is not a library, I have tested it to work on stm32f103c8t6 and use it in production. https://github.com/nopnop2002/Arduino-STM32-CAN
Recently tried to use stm32f103zet6, but failed. No problem has been found yet, the phenomenon is that Can initialization failed
https://github.com/nopnop2002/Arduino-STM32-CAN
On a Nucleo F303 works great, only if the RX and/or TX get some noise on the board, CAN initialization fails sometimes (e.g. connecting only a scope and no CAN transceiver connected)
Thanks for posting, helped me out big time!
Activity
fpistm commentedon Jun 2, 2018
Currently, there is no CAN support
Vicky-S commentedon Jun 2, 2018
Ok. will it be available in future?
fpistm commentedon Jun 2, 2018
Yes but I can't tell when...
Vicky-S commentedon Jun 2, 2018
Ok... Please try to make support ASAP..
BennehBoy commentedon Feb 11, 2019
@fpistm, by no support you mean there is no library right? So people could program directly against HAL CAN modules?
fpistm commentedon Feb 11, 2019
@BennehBoy
Yes of course. All STM32 features are available thanks HAL/LL (if user enable the right HAL module).
All stuff which can be done thanks the cube are available. By no support I told about Arduino point of view, there is no dedicated library to support STM32 CAN for this core with specific Arduino API style
[-]CAN communication support not available for STM32F746[/-][+]CAN communication support[/+]jacky4566 commentedon Nov 11, 2019
Bump. Would love to see some CAN bus support. Seems silly to buy a standalone SPI chip when all you need is a transceiver.
fpistm commentedon Nov 12, 2019
Hi @jacky4566
I'd love too.
I know @geosmall made some work around CAN:
https://github.com/geosmall/UAVCAN-for-STM32-Arduino
seeers commentedon Jan 8, 2020
Unfortunately the UAVCAN example only works with the STM32Duino version 1.4.
With version 1.8 I get the following errors:
`
sketch\can.c: In function 'MX_CAN_Init':
can.c:12: error: 'CAN_InitTypeDef' {aka 'struct '} has no member named 'SJW'
12 | hcan.Init.SJW = CAN_SJW_1TQ;
| ^
can.c:13: error: 'CAN_InitTypeDef' {aka 'struct '} has no member named 'BS1'
13 | hcan.Init.BS1 = CAN_BS1_1TQ;
| ^
can.c:14: error: 'CAN_InitTypeDef' {aka 'struct '} has no member named 'BS2'
14 | hcan.Init.BS2 = CAN_BS2_1TQ;
| ^
can.c:15: error: 'CAN_InitTypeDef' {aka 'struct '} has no member named 'TTCM'
15 | hcan.Init.TTCM = DISABLE;
| ^
can.c:16: error: 'CAN_InitTypeDef' {aka 'struct '} has no member named 'ABOM'
16 | hcan.Init.ABOM = DISABLE;
| ^
can.c:17: error: 'CAN_InitTypeDef' {aka 'struct '} has no member named 'AWUM'
17 | hcan.Init.AWUM = DISABLE;
| ^
can.c:18: error: 'CAN_InitTypeDef' {aka 'struct '} has no member named 'NART'
18 | hcan.Init.NART = DISABLE;
| ^
can.c:19: error: 'CAN_InitTypeDef' {aka 'struct '} has no member named 'RFLM'
19 | hcan.Init.RFLM = DISABLE;
| ^
can.c:20: error: 'CAN_InitTypeDef' {aka 'struct '} has no member named 'TXFP'
20 | hcan.Init.TXFP = DISABLE;
| ^
exit status 1
'CAN_InitTypeDef' {aka 'struct '} has no member named 'SJW'
`
Is there maybe an easy way to get it running with the current version?
fpistm commentedon Jan 8, 2020
@seeers
I think this is due to STM32F1 HAL update.
looking at the Release_Notes.html:
https://htmlpreview.github.io/?https://github.com/stm32duino/Arduino_Core_STM32/blob/master/system/Drivers/STM32F1xx_HAL_Driver/Release_Notes.html
From version V1.1.3 / 09-October-2018:
It seems there is an
HAL_CAN_LEGACY_MODULE_ENABLEDwhich can be enabled to use the legacy one butHAL_CAN_MODULE_ENABLEDhave to be disabled.25 remaining items
fpistm commentedon Nov 30, 2020
Hi @pazi88
Which F4 boards you used ? did you defined the
HAL_CAN_MODULE_ENABLED?https://github.com/stm32duino/wiki/wiki/HAL-configuration#hal-modules-configuration
shaneyake commentedon Dec 3, 2020
Does anybody know of a library that will work with the HAL_FDCAN_MODULE_ENABLED?
@J-f-Jensen library is great but I can't get it to compile for my Nucleo-H743IZ2.
or is there a way to use HAL_CAN_MODULE_ENABLED with the Nucleo-H743IZ2?
Thanks
pazi88 commentedon Dec 3, 2020
@shaneyake The library only works for F1 series as far as I know, because that's the only one using AFIO for pin mapping. F4 andvothets have different way to map pins, so that's why it wont compile (as I mentioned above).
lara105 commentedon May 8, 2022
any progress on this? would be very useful to have can support...
pazi88 commentedon May 8, 2022
You can use this library I created. Uses HAL drivers, hadware interrupts and it's easy to use. Should work with every stm32 chip that is supported by stm32duino: https://github.com/pazi88/STM32_CAN
pazi88 commentedon May 8, 2022
I have been meaning to do some last modifications to that and maybe make a PR for that to be added in stm32core. I have been personally used that with many projects communicating busy vehicle CAN busses and it works great (other ones I have found, have many problems).
lara105 commentedon May 8, 2022
Wow thanks @pazi88 will test tomorrow! Was previously using MBed but it is failing with high bus loads....
fpistm commentedon May 9, 2022
Hi @pazi88, do not hesitate to male a PR or you can also share it as an Arduino library.
pazi88 commentedon May 9, 2022
Yes with other libraries available I also had problems with high bus loads, but with this one all seems fine, because both TX and RX side are interrupt based and the packets are gathered to buffers that have configurable size.
pazi88 commentedon May 9, 2022
It works already as Arduino library. But I'll do those additions I have been meaning to do and do a PR then.
ChinaBurn commentedon May 25, 2022
There is a working Can instance here, but this is not a library, I have tested it to work on stm32f103c8t6 and use it in production.
https://github.com/nopnop2002/Arduino-STM32-CAN
Recently tried to use stm32f103zet6, but failed. No problem has been found yet, the phenomenon is that Can initialization failed
wltue commentedon Jun 19, 2024
https://github.com/nopnop2002/Arduino-STM32-CAN
On a Nucleo F303 works great, only if the RX and/or TX get some noise on the board, CAN initialization fails sometimes (e.g. connecting only a scope and no CAN transceiver connected)
Thanks for posting, helped me out big time!