@@ -25,8 +25,11 @@ fn main() -> ! {
25
25
// To meet CAN clock accuracy requirements an external crystal or ceramic
26
26
// resonator must be used. The blue pill has a 8MHz external crystal.
27
27
// Other boards might have a crystal with another frequency or none at all.
28
- rcc. cfgr
29
- . hse ( HSEClock :: new ( 8 . mhz ( ) , HSEClockMode :: Bypass ) )
28
+ let _clocks = rcc
29
+ . cfgr
30
+ . hse ( HSEClock :: new ( 25 . mhz ( ) , HSEClockMode :: Bypass ) )
31
+ . sysclk ( 216 . mhz ( ) )
32
+ . hclk ( 216 . mhz ( ) )
30
33
. freeze ( ) ;
31
34
32
35
let gpioa = dp. GPIOA . split ( ) ;
@@ -40,9 +43,9 @@ fn main() -> ! {
40
43
bxcan:: Can :: new ( can)
41
44
} ;
42
45
can1. configure ( |config| {
43
- // APB1 (PCLK1): 8MHz , Bit rate: 125kBit /s, Sample Point 87.5%
46
+ // APB1 (PCLK1): 130MHz , Bit rate: 512kBit /s, Sample Point 87.5%
44
47
// Value was calculated with http://www.bittiming.can-wiki.info/
45
- config. set_bit_timing ( 0x001c_0003 ) ;
48
+ config. set_bit_timing ( 0x001e_000b ) ;
46
49
} ) ;
47
50
48
51
// Configure filters so that can frames can be received.
@@ -57,9 +60,9 @@ fn main() -> ! {
57
60
58
61
let mut can2 = bxcan:: Can :: new ( can) ;
59
62
can2. configure ( |config| {
60
- // APB1 (PCLK1): 8MHz , Bit rate: 125kBit /s, Sample Point 87.5%
63
+ // APB1 (PCLK1): 130MHz , Bit rate: 512kBit /s, Sample Point 87.5%
61
64
// Value was calculated with http://www.bittiming.can-wiki.info/
62
- config. set_bit_timing ( 0x001c_0003 ) ;
65
+ config. set_bit_timing ( 0x001e_000b ) ;
63
66
} ) ;
64
67
65
68
// A total of 28 filters are shared between the two CAN instances.
0 commit comments