STM32F769 CAN3 Topic is solved
STM32F769 CAN3
Hi,
is there anybody who's implementing CAN3 for the STM32F7 or is this work in the pipe?
If not, what are the steps to do this?
I saw that the CAN3 has to be added to the stm32_registry.h file.
CAN3 has its own filter banks.
Thanks.
is there anybody who's implementing CAN3 for the STM32F7 or is this work in the pipe?
If not, what are the steps to do this?
I saw that the CAN3 has to be added to the stm32_registry.h file.
CAN3 has its own filter banks.
Thanks.
- Giovanni
- Site Admin
- Posts: 14893
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: STM32F769 CAN3
Hi,
It is not scheduled yet, it should not be complex to do following the driver patterns.
Giovanni
It is not scheduled yet, it should not be complex to do following the driver patterns.
Giovanni
Re: STM32F769 CAN3
Hi,
here is my initial version. You were right. Is was not very complex to implement CAN3 following the driver patterns.
Just one thing is not that easy. The function can_lld_set_filters is written to have just CAN1 and CAN2 were CAN2 is the slave of CAN1. But CAN3 is a master CAN with its own receive filter banks. Therefore i added the driver handle pointer to the input paramter of can_lld_set_filters and canSTM32SetFilters.
I had also to modify the stm32_registry.h because of the interrupt vectors of CAN3 and stm32_rcc.h because of rccResetCAN3, rccEnableCAN3 and rccDisableCAN3.
Thanks for feedback.
here is my initial version. You were right. Is was not very complex to implement CAN3 following the driver patterns.
Just one thing is not that easy. The function can_lld_set_filters is written to have just CAN1 and CAN2 were CAN2 is the slave of CAN1. But CAN3 is a master CAN with its own receive filter banks. Therefore i added the driver handle pointer to the input paramter of can_lld_set_filters and canSTM32SetFilters.
I had also to modify the stm32_registry.h because of the interrupt vectors of CAN3 and stm32_rcc.h because of rccResetCAN3, rccEnableCAN3 and rccDisableCAN3.
Thanks for feedback.
Last edited by neums on Fri Nov 04, 2016 11:37 am, edited 1 time in total.
Re: STM32F769 CAN3
There was also a bug when configuring the rx filters of CAN2 in can_lld_set_filters(). Modified it in hal_can_lld.c from:
to
CAN_FMR_FINIT has to be set before writing can2sb to the register.
Another change in hal_can_lld.c - canSTM32SetFilters() from:
to
I set the check of can2sb to 0 and to STM32_CAN_MAX_FILTERS because due to the reference manual RM0090 (STM32F4 chapter 32.9.4 CAN filter registers - CAN filter master register (CAN_FMR)) these values are valid.
In the reference manual of the STM32F769 (RM0410) it is not stated as valid but it work also. I asked for that fact in the STM forum:
STM32F769 CAN2
Please consider the new patch.
Code: Select all
#if STM32_CAN_USE_CAN1
if(canp == &CAND1) {
rccEnableCAN1(FALSE);
/* Filters initialization.*/
canp->can->FMR = (canp->can->FMR & 0xFFFF0000) | (can2sb << 8) | CAN_FMR_FINIT;
}
#endif
to
Code: Select all
#if STM32_CAN_USE_CAN1
if(canp == &CAND1) {
rccEnableCAN1(FALSE);
/* Filters initialization.*/
canp->can->FMR = (canp->can->FMR & 0xFFFF0000) | CAN_FMR_FINIT;
canp->can->FMR = (canp->can->FMR & 0xFFFF0000) | (can2sb << 8) | CAN_FMR_FINIT;
}
#endif
CAN_FMR_FINIT has to be set before writing can2sb to the register.
Another change in hal_can_lld.c - canSTM32SetFilters() from:
Code: Select all
#if STM32_CAN_USE_CAN2
osalDbgCheck((can2sb >= 1) && (can2sb < STM32_CAN_MAX_FILTERS) &&
(num <= STM32_CAN_MAX_FILTERS));
#endif
to
Code: Select all
#if STM32_CAN_USE_CAN2
osalDbgCheck((can2sb >= 0) && (can2sb <= STM32_CAN_MAX_FILTERS) &&
(num <= STM32_CAN_MAX_FILTERS));
#endif
I set the check of can2sb to 0 and to STM32_CAN_MAX_FILTERS because due to the reference manual RM0090 (STM32F4 chapter 32.9.4 CAN filter registers - CAN filter master register (CAN_FMR)) these values are valid.
In the reference manual of the STM32F769 (RM0410) it is not stated as valid but it work also. I asked for that fact in the STM forum:
STM32F769 CAN2
Please consider the new patch.
- Attachments
-
- STM32F7_CAN3_patch.zip
- (15.31 KiB) Downloaded 551 times
- Giovanni
- Site Admin
- Posts: 14893
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: STM32F769 CAN3
Hi,
Thanks, I will look into merging the changes.
Moving this thread in "bug reports".
Giovanni
Thanks, I will look into merging the changes.
Moving this thread in "bug reports".
Giovanni
- Giovanni
- Site Admin
- Posts: 14893
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: STM32F769 CAN3
Hi,
I merged the patch but had to make some changes, there were problems. The driver didn't compile on other STM32s and there were other things to be added.
Please verify if it works for you.
Giovanni
I merged the patch but had to make some changes, there were problems. The driver didn't compile on other STM32s and there were other things to be added.
Please verify if it works for you.
Giovanni
- Giovanni
- Site Admin
- Posts: 14893
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: STM32F769 CAN3
Hi,
It has been added to the trunk code, it will be present in the next release, 17.2.0 likely.
Giovanni
It has been added to the trunk code, it will be present in the next release, 17.2.0 likely.
Giovanni