2023-06-22 11:42 AM
Hello I am trying to attempt a CANBUS communication between two different STM boards, I've been following the videos on the STM website as a reference and I got the LOOPBACK Mode to work with one STM board but I am having trouble getting the NORMAL mode to work with two Stm boards.
Video I am referencing: https://youtu.be/KHNRftBa1Vc
My Master board is a Nucleo-L4R5ZI-P
Slave board is a Nucleo-L4A6ZG
Attached is an image of my current setup on trying to get the CAN transmit working
I kept the code mostly the same as the video, the problem I have right now is when I run it the video doesn't clarify if I should run the slave first then the master or run them in debug mode, doing either method I am getting all sorts of errors or just nothing happening, any clarification on what I can do to fix this would be massive help, Thank you!
2023-06-23 08:07 AM
I believe that I am close so I want to continue tinkering with the current setup I have in order to make it work similar to the video, but if it becomes too much of a frustration I will take your advice and go back a bit to get it working that way.
2023-06-23 08:08 AM
The Issue for me is that im kind of stuck using the ST32 IDE for deadline related reasons and im not confident I can learn a different IDE of this moment, I will read through the document you linked and hopefully that will open up something for me.
2023-06-23 08:39 AM
2023-06-23 09:43 AM
So looking at the debugger mode I've discovered that the error for both boards happens when it Initializes the RCC Oscillators, don't know if that gives any insight to anyone?
2023-06-27 01:54 AM
Hi,
I told you to change the CAN prescaler value as well as BS1 and BS2 values as they are not safe? did you do that?
2023-06-27 02:40 AM
Hi again,
Just noticed that the video you're watching doesn't seem to use the same boards as you! Moreover, there are some "bubull**bleep**":
- Nucleo board doesn't have a Crystal mounted on it while he selected Crystal / HSE as system source clock.
- The CAN parameters are not safe: prescaler, BSA, and BS2.
I don't know how this worked for him!!
According to Nucleo-L4A6ZG and Nucleo-L4R5ZI-P schematics, there is no crystal external mounted on the boards. The only solution you have is to use the clock generated by STLink (MCO).
So, according to the schematic, you have to solder SB109 as well as SB148 to connect MCO output from STLink to OSC-IN of the STM32L4xx.
Also you have to configure HSE in bypass mode.
I've attached CubeMx project for STM32L4A6ZG: clock at 80Mhz, CAN bitrate at 500kb/s with reasonable parameters:
You can do the same thing for STM32L4R5ZI.
Hope it helps you.
2023-06-27 11:55 AM - edited 2023-06-27 11:58 AM
Yeah so I did eventually figure out that my board did not have a HSE option being valid so I've been playing around with HSI as the clock rate, Regarding the CubeMX project that you have just attached is this the configuration for soldering the SB109 as well as the SB148 to the MCO? If so I'll try and see if that works but I think I will have to purchase the components for that. Right now with the changes I've made to clock and CAN rate I don't go into any error handlers but I have been unable to receive a message on either micro controller. Will Let you know if I get it to work with your suggestions!
2023-06-27 02:28 PM
So I soldered the SB109 to SB148 like you said and the clock configuration Is using MSI as the PLL source mux to the PLLCLK as the system Clock mux with a Hclk and SYSclk of 80MHZ. Im using BYPASS block source for the HSE but I tried using HSE for the source mux and it wouldnt let me do 80mhz with that config. Did I miss a step in the instructions you gave?
2023-06-30 02:21 AM - edited 2023-06-30 02:24 AM
Hi
First, IT'S NOT RECOMMENDED to use any internal clock source for CAN communication i.e. HSI, MSI etc.
Second, you said "I soldered the SB109 to SB148"! what do you mean by "to"? you soldered all the solder bridges from SB109 to SB148 or soldered SB109 to SB148? the idea is to solder SB109 AND SB148. Please refer to your board schematics to understand the modification and the idea behind.
Third, the idea of soldering SB109 to SB148 is to connect the external clock source generated by the STLink to OSC-IN. But when you say you are configuring MSI as source clock, soldering SB109 and SB148 has no effect.
I tried to attach the .ioc file for you but did not succeed due to a limitation on the new forum (I raised the issue internally, hope it will be fixed asap).
So I'm attaching the screen shot of the clock config.
2023-06-30 10:28 AM - edited 2023-06-30 11:27 AM
Okay I understand, Yes I soldered SB109 and SB148, I followed the screenshot you had for the clock config but the program for the NUCLEO-L4R5ZI-P appears to get stuck in SysTick_Handler and never goes out of it. It would be very helpful to get the full .ioc but I appreaciate the help you've given so far. Am I to understand that I should not be using the MCO option in RCC? Currently having it unchecked the program will get stuck in SysTick_Handler at some point but when I have it enabled I am not sure what source mux to choose. Again really appreciate the help so far and looking forward to a response!