diff options
| author | robert-hh <robert@hammelrath.com> | 2024-02-22 09:03:06 +0100 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2024-08-20 12:26:45 +1000 |
| commit | 7270b871c248a4a091d310ec59eca4138a3e96e3 (patch) | |
| tree | 6e1726de2d6c73276fa856c7dedaf72df6566de5 /docs/rp2 | |
| parent | d420b4e478267cf8c6c0136982bdeeedaccf3920 (diff) | |
rp2/modmachine: Set the peripheral frequency with machine.freq().
By default, the peripheral clock for UART and SPI is set to 48 MHz and will
not be affected by the MCU clock change. This can be changed by a second
argument to `machine.freq(freq, peripheral_freq)`. The second argument
must be either 48 MHz or identical with the first argument.
Note that UART and SPI baud rates may have to be re-configured after
changing the MCU clock.
Signed-off-by: robert-hh <robert@hammelrath.com>
Diffstat (limited to 'docs/rp2')
| -rw-r--r-- | docs/rp2/quickref.rst | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/docs/rp2/quickref.rst b/docs/rp2/quickref.rst index ecf3f3186..9b82ea5dc 100644 --- a/docs/rp2/quickref.rst +++ b/docs/rp2/quickref.rst @@ -31,12 +31,25 @@ The MicroPython REPL is accessed via the USB serial port. Tab-completion is usef find out what methods an object has. Paste mode (ctrl-E) is useful to paste a large slab of Python code into the REPL. -The :mod:`machine` module:: +The :mod:`machine` module: + +machine.freq() allows to change the MCU frequency and control the peripheral +frequency for UART and SPI. Usage:: + + machine.freq(MCU_frequency[, peripheral_frequency=48_000_000]) + +The MCU frequency can be set in a range from less than 48 MHz to about 250MHz. +The default at boot time is 125 MHz. The peripheral frequency must be either +48 MHz or identical to the MCU frequency, with 48 MHz as the default. +If the peripheral frequency is changed, any already existing instance of +UART and SPI will change it's baud rate and may have to be re-configured:: import machine machine.freq() # get the current frequency of the CPU - machine.freq(240000000) # set the CPU frequency to 240 MHz + machine.freq(240000000) # set the CPU frequency to 240 MHz and keep + # the UART frequency at 48MHz + machine.freq(125000000, 125000000) # set the CPU and UART frequency to 125 MHz The :mod:`rp2` module:: |
