2024-12-26 12:06 AM - last edited on 2024-12-26 12:14 AM by SofLit
Hi all
I am using STM32F407 and trying to configure both CAN1 AND CAN2 so I want to understand a concept hope you people can help me. CAN1(MASTER) and CAN2(SLAVE) .
I want to achieve operation to send data from one can to another and vice versa.
NOTE: In my STM32F407 reference manual FILTER register is only configurable for CAN1 not for CAN2.
I have few doubts one by one I will mention.
1. for CAN1's filter configuration what should be the value for slave filterbank I should select.
2.If CAN2 doesn't have filter configuration so how it will receive the data(will it receive every ID because we cant configure filters).
PFA attached from STM32F407 reference manual image.
B.R
Ash
Solved! Go to Solution.
2024-12-26 02:19 AM - edited 2024-12-26 05:06 AM
If you are not using CubeMx, you should enable CAN1 RCC clock first to ensure CAN1 could manage the filters. Then do what you do: configure CAN1 first or CAN2 first.. It's up to you.
The filters could be configured at any stage no matter the position of the configuration in CAN1 or CAN2 config or outside. The most important thing is to enable the CAN1 RCC clock and the filters are configured in CAN1 registers even for CAN2. The Slave Start Bank parameter decides what filter block will be used by CAN1 or CAN2.
2024-12-26 12:11 AM - edited 2024-12-26 12:14 AM
Hi @Ash1
Please don't duplicate threads. https://community.st.com/t5/stm32-mcus-products/can1-and-can2-for-stm32f407evb/td-p/756275
Regarding your first question, please refer to this article.
For your second question, indeed filters should be enabled and need to configure the correct filter number according to the start filter bank. The filters are shared between CAN1 and CAN2. The slave Start Bank is here to separate the filter bank used by CAN1 and CAN2. Also refer to the same article.
2024-12-26 01:18 AM - edited 2024-12-26 01:56 AM
Hi
In this thread my question was totally different in future I will avoid duplicate threads.
I just wanted know when filter configurations register are not available in CAN2 then how can I configure it for reception . This was my question. I have read the article that you have mentioned above.
NOTE: bxCAN register map
Refer to Section 2.3: Memory map for the register boundary addresses. The registers from
offset 0x200 to 31C are present only in CAN1. (this is mention in reference manual)
mean to say filter register like CAN_FMR,FMIR,FSIR,FFAIR,FAIR,FoR1 these register are only for CAN1 so how I will configure filters for CAN2 SLAVE this was my querry
B.R
Ash
2024-12-26 02:08 AM - edited 2024-12-26 02:11 AM
@Ash1 wrote:
Hi
In this thread my question was totally different .
The text is different, but the question is almost the same.
@Ash1 wrote:
NOTE: bxCAN register map
Refer to Section 2.3: Memory map for the register boundary addresses. The registers from
offset 0x200 to 31C are present only in CAN1. (this is mention in reference manual)mean to say filter register like CAN_FMR,FMIR,FSIR,FFAIR,FAIR,FoR1 these register are only for CAN1 so how I will configure filters for CAN2 SLAVE this was my querry
I've already stated that CAN filters are shared between CAN1 and CAN2. CAN1 is master from architecture point of view and especially on filter block.
In the bxCAN register map, there is this statement: "The registers from offset 0x200 to 31C are present only in CAN1."
That's because the filter registers starting from CAN_FMR (starting from 0x200 offset) are not available on CAN2 and they are managed by CAN1.
That's why if you are using only CAN2. You should enable CAN1 RCC clock even you will not use it (not to be configured), because it manages the filter block and you will configure the filtering on CAN1 registers even you are using CAN2.
Again please read the article.
Hope it's clear now.
2024-12-26 02:13 AM
Hi
So What IF I am configuring both CAN1 and CAN2 so only I have to do filter configuration for CAN1 at the time of CAN1 intialisation (and I will make slavefilterbank as 10 so rest will be for CAN2), not at the time of CAN2 intialisation.
B.R
Ash
2024-12-26 02:15 AM
Did you read the article.?
2024-12-26 02:19 AM - edited 2024-12-26 05:06 AM
If you are not using CubeMx, you should enable CAN1 RCC clock first to ensure CAN1 could manage the filters. Then do what you do: configure CAN1 first or CAN2 first.. It's up to you.
The filters could be configured at any stage no matter the position of the configuration in CAN1 or CAN2 config or outside. The most important thing is to enable the CAN1 RCC clock and the filters are configured in CAN1 registers even for CAN2. The Slave Start Bank parameter decides what filter block will be used by CAN1 or CAN2.