@@ -33,6 +33,10 @@ struct SystemClock
33
33
static constexpr uint32_t Spi0 = Mck;
34
34
static constexpr uint32_t Twihs0 = Mck;
35
35
static constexpr uint32_t Dacc = Mck;
36
+
37
+ static constexpr uint32_t Pck5 = 80_MHz;
38
+ static constexpr uint32_t Mcan = Pck5;
39
+
36
40
// static constexpr uint32_t Usb = 48_MHz;
37
41
38
42
static bool inline
@@ -47,6 +51,16 @@ struct SystemClock
47
51
ClockGen::selectMasterClk<MasterClkSource::PLLA_CLK, MasterClkPrescaler::CLK_1, MasterClkDivider::Div2>();
48
52
ClockGen::updateCoreFrequency<Frequency>();
49
53
54
+ // Enable PMC bus-independent clock output PCK5 for MCAN
55
+ // Manual (48.4.2): "It is recommended to use the CAN clock at frequencies of 20, 40 or 80 MHz.
56
+ // To achieve these frequencies, PMC PCK5 must select the UPLLCK (480 MHz) as source clock and
57
+ // divide by 24, 12, or 6. PCK5 allows the system bus and processor clock to be modified
58
+ // without affecting the bit rate communication."
59
+ ClockGen::enableUPll<UtmiRefClk::Xtal12>();
60
+ ClockGen::disablePck (Pck::Pck5);
61
+ ClockGen::configurePck (Pck::Pck5, PckSource::UPll, 6 );
62
+ ClockGen::enablePck (Pck::Pck5);
63
+
50
64
return true ;
51
65
}
52
66
};
@@ -70,6 +84,16 @@ using Scl = GpioA4;
70
84
71
85
using LoggerDevice = modm::IODeviceWrapper<Debug::Uart, modm::IOBuffer::BlockIfFull>;
72
86
87
+ namespace Can
88
+ {
89
+ // / @ingroup modm_board_samv71_xplained_ultra
90
+ // / @{
91
+ using Rx = GpioC12;
92
+ using Tx = GpioC14;
93
+ using Can = Mcan1;
94
+ // / @}
95
+ }
96
+
73
97
inline void
74
98
initialize ()
75
99
{
@@ -87,6 +111,8 @@ initialize()
87
111
88
112
Leds::setOutput ();
89
113
ButtonSW0::setInput (InputType::PullUp);
114
+
115
+ Can::Can::connect<Can::Rx::Rx, Can::Tx::Tx>(InputType::PullUp);
90
116
}
91
117
92
118
/*
0 commit comments