2021-12-08 11:08 PM
Hello forum users!
Created a project by example
[url] https://istarik.ru/blog/stm32/159.html [/ url]
Slightly corrected, so that a new frame is sent every 10 msec.
The project works at (except one) any speed (100kbit - works, 500, 800 - works).
Data is transmitted and received by a usb-can converter (sys tec elecronic).
Here, for example, I configured the project for a CAN speed of 500kbit / s:
- here is the CAN tincture:
[url = http: //vfl.ru/fotos/6049ccb837010333.html] [img] http://images.vfl.ru/ii/1638964027/6049ccb8/37010333_m.jpg [/ img] [/ url]
- and here is the frequency setting:
[url = http: //vfl.ru/fotos/d34be44637010398.html] [img] http://images.vfl.ru/ii/1638964156/d34be446/37010398_m.jpg [/ img] [/ url]
-and this data is received at a speed of 500 kbps:
[url = http: //vfl.ru/fotos/2ec1947737010697.html] [img] http://images.vfl.ru/ii/1638965166/2ec19477/37010697_m.jpg [/ img] [/ url]
- this is the picture on the CAN bus:
[url = http: //vfl.ru/fotos/d52d156337010759.html] [img] http://images.vfl.ru/ii/1638965437/d52d1563/37010759_m.jpg [/ img] [/ url]
************************************************* *********
Okay, reconfiguring the speed to 1Mbps.
To do this, you just need to change the CAN frequency divider from 4 to 2.
And Cube kindly calculates the bus speed:
[url = http: //vfl.ru/fotos/75dbe36237010531.html] [img] http://images.vfl.ru/ii/1638964501/75dbe362/37010531_m.jpg [/ img] [/ url]
I'm flashing the microcontroller and that's it. Data is not accepted :(, but on the bus this is the picture:
- to fit everything into the monitor, I had to change the sweep to 100msec !!!!
[url = http: //vfl.ru/fotos/b265ca8237010856.html] [img] http://images.vfl.ru/ii/1638965896/b265ca82/37010856_m.jpg [/ img] [/ url]
At the same time, if you look at the status of the registers, then CAN reports and sets error bits:
[url = http: //vfl.ru/fotos/75f6ccfa37010945.html] [img] http://images.vfl.ru/ii/1638966181/75f6ccfa/37010945_m.jpg [/ img] [/ url]
LEC Bits in ESR Register: 101: Bit dominant Error
Why does stm32 not want to work at a CAN speed of 1 Mbit / s ???
2021-12-09 02:43 AM
Hello @Nikolai_Werenich ,
Could you please increase the system clock to 72MHz (AHB prescaler = 1, APB1 prescaler = 2)?
Also for the sample point it's recommended to set it at about 88% of the bit time at higher bitrates.