
How to Overclock and Overclock a Raspberry Pi Pico
Overclocking any Raspberry Pi mannequin actually easy. Nevertheless, overclocking Raspberry Pi Pico even easier. All it takes is 2 traces of MicroPython and your Pico can simply double its regular velocity and wish no different program. finest CPU coolers.
This fashion we’ll overclock a Raspberry Pi Pico to 270 MHz, doubling the bottom velocity of 133 MHz. Subsequent, we’ll write a script to check how a lot we are able to overclock, after which how slowly we are able to overclock the CPU.
Why would I overclock a Raspberry Pi Pico? It might probably emulate retro computer systems just like the ZX Spectrum and Commodore 64. Overclocking with MicroPython provides us a noticeable velocity increase and if we’re utilizing it in a battery powered challenge, overclocking may give us longer battery life.
That is the way it will work with the Raspberry Pi Pico, Piko Ok and lots of different finest RP2040 based mostly motherboards When utilizing MicroPython. There are different strategies to vary the frequency when programming boards in different languages.
You Will Want For This Challenge
Raspberry Pi Pico or Pico W or any RP2040 based mostly board operating MicroPython.
Tips on how to Overclock Raspberry Pi Pico with MicroPython
one. Set up the most recent model of MicroPython in your Pico. If you have not executed this but, comply with step three of this information to learn how
2. Import machine module in REPL And Examine the present velocity of Raspberry Pi Pico. The worth returned will seemingly be 125000000 Hertz (125 MHz). Some boards or variations of MicroPython could have it set slightly larger by default.
import machine
machine.freq()
3. Utilizing the identical command, Set the CPU velocity to 270 MHz.
machine.freq(270000000)
4. Examine CPU velocity to verify the overclock is working. The returned worth ought to be 270000000 Hertz (270 MHz).
machine.freq()
At present, this velocity enhance is momentary. When Pico reboots, it goes again to its default velocity (often 125 MHz). To keep up overclocking, overclocking have to be set every time the Pico is turned on. Including these two traces to the start of any MicroPython code will overclock the RP2040 to the specified velocity when the code is run.
import machine
machine.freq(SPEED IN HERTZ)
How Arduous Can the RP2040 Be?
Overclockers at all times need to go slightly sooner, however how will we set our possibilities within the silicon lottery? For this, we’ve got automated the method with slightly Python code.
1. At Tonny begin a brand new file with importing two modules first. The machine is used to vary the CPU velocity and the time is used to hurry up the code.
import machine
import time
2. Create a variable, frequency, and save 270 MHz as Hertz. We all know that 270 MHz works effectively, so we begin from a recognized working velocity. In case your objective is to decelerate the RP2040, cut back the worth accordingly.
freq = 270000000
3. Create an object, velocity up, and retailer the RP2040’s present velocity there. Utilizing slightly math, the returned worth in Hertz is transformed to megahertz, then rounded to at least one decimal place and at last transformed to a string.
velocity = str(spherical(machine.freq()/1000000,1))
4. Print the present CPU velocity as a part of a message. We would have liked to transform the speed to a string to embed it within the message.
print("The beginning velocity is",velocity,"MHz")
5. Print a message to the consumer that the check will start in 5 seconds, after which wait 5 seconds.
print("Beginning the check in 5 seconds")
time.sleep(5)
6. Create a loop to run the code repeatedly. We will use a for loop, however the whereas True loop will crash if it hits a foul frequency, so we achieve nothing from a for loop.
whereas True:
7. Set the CPU velocity utilizing the freq variable.
machine.freq(freq)
8. Create an object, velocity up, and retailer the RP2040’s present velocity there. Utilizing slightly math, the worth returned in Hertz is transformed to MegaHertz, then rounded to at least one decimal place and at last transformed to a string.
velocity = str(spherical(machine.freq()/1000000,1))
9. Print the present CPU velocity as a part of a message. We would have liked to transform the speed to a string to embed it within the message.
print("The beginning velocity is",velocity,"MHz")
10. Improve the velocity by 10 MHz and save the worth in freq. The += operator interprets as freq = freq + 10000000. It’s shorter and neater in code. Each work equally and will be modified for readability. += will be changed with -= so the values rely down to seek out the bottom CPU velocity.
freq += 10000000
eleventh. Pause the code for 2 seconds. This can give us time to learn the values earlier than the loop repeats.
time.sleep(2)
12. Save the code as speedtest.py on Raspberry Pi Pico and click on run. Our greatest velocity was 280 MHz, however you is likely to be in luck.
We additionally examined overclocking (lowering the velocity by 10 MHz per cycle) and have been in a position to cut back it to 10 MHz, which is able to considerably cut back energy consumption for tasks that require lengthy battery life. We have been unable to seize any information because of the stage of precision tools required.
Full Code Listing
import machine
import time
freq = 270000000
velocity = str(spherical(machine.freq()/1000000,1))
print("The beginning velocity is",velocity,"MHz")
print("Beginning the check in 5 seconds")
time.sleep(5)
whereas True:
machine.freq(freq)
velocity = str(spherical(machine.freq()/1000000,1))
print("The present velocity is",velocity,"MHz")
freq += 10000000
time.sleep(2)
#Overclock #Overclock #Raspberry #Pico