@@ -321,12 +321,13 @@ def _clock_pwm_deinit(self):
321
321
self ._clock_pwm .deinit ()
322
322
self ._clock_pwm = None
323
323
324
- def clock_project_PWM (self , freqHz :int , duty_u16 :int = (0xffff / 2 ), quiet :bool = False ):
324
+ def clock_project_PWM (self , freqHz :int , duty_u16 :int = (0xffff / 2 ), quiet :bool = False , max_rp2040_freq : int = 133_000_000 ):
325
325
'''
326
326
Start an automatic clock for the selected project (using
327
327
PWM).
328
328
@param freqHz: The frequency of the clocking, in Hz, or 0 to disable PWM
329
- @param duty_u16: Optional duty cycle (0-0xffff), defaults to 50%
329
+ @param duty_u16: Optional duty cycle (0-0xffff), defaults to 50%
330
+ @param max_rp2040_freq: Maximum RP2040 frequency, overclocking above 133MHz allows higher clock frequencies
330
331
'''
331
332
if freqHz > 0 :
332
333
self .pins .project_clk_driven_by_RP2040 (True )
@@ -353,8 +354,10 @@ def clock_project_PWM(self, freqHz:int, duty_u16:int=(0xffff/2), quiet:bool=Fals
353
354
if self ._clock_pio is not None :
354
355
self ._clock_pio .stop ()
355
356
try :
356
- rp2040_sys_clock = self ._get_best_rp2040_freq (freqHz )
357
- platform .set_RP_system_clock (rp2040_sys_clock )
357
+ rp2040_sys_clock = self ._get_best_rp2040_freq (freqHz , max_rp2040_freq )
358
+ if rp2040_sys_clock != platform .get_RP_system_clock ():
359
+ log .info (f'Setting RP2040 system clock to { rp2040_sys_clock } Hz' )
360
+ platform .set_RP_system_clock (rp2040_sys_clock )
358
361
self ._clock_pwm = self .pins .rp_projclk .pwm (freqHz , duty_u16 )
359
362
except Exception as e :
360
363
log .error (f"Could not set project clock PWM: { e } " )
0 commit comments