2021-06-16 06:44 AM
The thing is, that i have no problem with the communication on 22408 Bits. I used the parameters:
My clock configuration is attached. I used the same parameters on the PCAN, but there is no message sendet. Is there any connection from the Baudrate with the clock frequency that could create the problem? There is no error in my compiling btw.
Solved! Go to Solution.
2021-06-22 02:00 AM
@NDorn.1
You can also use PLL with an external crystal to get the 48MHz for sysclock.
As you are using NUCLEO-F072RB board, the external clock is provided to your MCU in bypass mode and generated by ST-Link module.
Attached a CubeMx project that configures your system clock at 48MHz, APB1 clock at 24MHz. And I don't see a link between your PCAN frequency config and the clock of your MCU.
Also as I said before it's not recommended for CAN communication to use the internal RC oscillator (HSI) and may be this was your issue.
Hope this can help you.
2021-06-21 05:56 AM
Hello,
First, as per your CubeMx config, you are using HSI as source clock for CAN which is not recommended and you risk to have some troubles with communications. So please select HSE as source clock.
Second, it's preferable to increase your Sysclock and use for example 48Mhz instead of 8Mhz and 24MHz for APB1.
May be I recommend the following:
I suppose your hardware is ok and you have added an external transceiver + terminal resistor based on your quote: "The thing is, that i have no problem with the communication on 22408 Bits."
STM32
2021-06-21 07:17 AM
Hello,
The can-transceiver i use is for can-speed up to 1Mbit/s and shouldnt be the problem.
Is there a specific reason to use an APB1CLKDivider? i have a maximum of 32MHz on my HSE and my PCAN can just accept 20MHz or 10 for example.
2021-06-21 07:28 AM
Hello,
I don't know what is PCAN.. is it a tool (HW + software)? I did't understand what do you mean by " i have a maximum of 32MHz on my HSE and my PCAN can just accept 20MHz or 10 for example." So, what is the link of HSE with your "PCAN"?
APB1 clock could be 1, 2 etc ..and it's preferable to increase CAN source clock to have more precise bit time. what I provided is just an example and APB1CLKDivider is a reasonable value and this config should work.
If it don't, I would recommend to use the loopback mode and measure your bit time on CAN_tx pin.
STM32
2021-06-22 12:19 AM
Sry, i thought PCAN is a common worksation for testing. PCAN is a Hardware to connect (send and receive) a CAN device with your PC. In the software of PCAN i can simulate CAN messages. It has to be synchronized with my CAN-Module of my MCU. I can choose between 20, 24, 30, 40, 60 and 80 MHz. As you can see in the screenshot of the clock configuration of my Stm32F072RB-nucleo my HSE has a range of 4-32MHz. to get 48MHz i have to use the HSI48-clock. I tried both, but it is still not working. So i asked if it is necessary that the APB1 is just 1/2 or less of the used systemclock as you said with "Second, it's preferable to increase your Sysclock and use for example 48Mhz instead of 8Mhz and 24MHz for APB1.". I know it is editable, but has it a reason to use that clkdivider. As i said my Hardware is aware of sending and getting messages until 1000 kBit/s normally and my wires are not even 1m long, so that shouldnt be the problem. I just dont get why it is working with 250kBit/s for example, but 500 or more are not working. So i came to the point that it has to be the clock-config that causes the problem. I hope you could follow me.
Best regards.
2021-06-22 02:00 AM
@NDorn.1
You can also use PLL with an external crystal to get the 48MHz for sysclock.
As you are using NUCLEO-F072RB board, the external clock is provided to your MCU in bypass mode and generated by ST-Link module.
Attached a CubeMx project that configures your system clock at 48MHz, APB1 clock at 24MHz. And I don't see a link between your PCAN frequency config and the clock of your MCU.
Also as I said before it's not recommended for CAN communication to use the internal RC oscillator (HSI) and may be this was your issue.
Hope this can help you.