diff --git a/adafruit_emc2101/__init__.py b/adafruit_emc2101/__init__.py index 8381713..828cdd0 100644 --- a/adafruit_emc2101/__init__.py +++ b/adafruit_emc2101/__init__.py @@ -53,6 +53,7 @@ _FAN_CONFIG = const(0x4A) _FAN_SPINUP = const(0x4B) _REG_FAN_SETTING = const(0x4C) +_PWM_FREQ = const(0x4D) _REG_PARTID = const(0xFD) # 0x16 _REG_MFGID = const(0xFE) # 0xFF16 @@ -202,14 +203,13 @@ class to add those features, at the cost of increased memory usage. `forced_ext_temp`""" _fan_setting = UnaryStruct(_REG_FAN_SETTING, " 0x1F: raise AttributeError("pwm_frequency must be from 0-31") - self._pwm_freq_div = value + self._pwm_freq = value + self._calculate_full_speed(pwm_f=value) @property def pwm_frequency_divisor(self): diff --git a/examples/emc2101_set_pwm_freq.py b/examples/emc2101_set_pwm_freq.py index 454f850..cc61a6a 100644 --- a/examples/emc2101_set_pwm_freq.py +++ b/examples/emc2101_set_pwm_freq.py @@ -10,7 +10,9 @@ emc = EMC2101(i2c) emc.set_pwm_clock(use_preset=False) # Datasheet recommends using the maximum value of 31 (0x1F) -# to provide the highest effective resolution +# to provide the highest effective resolution. +# The PWM frequency must be set before changing `manual_fan_speed` or LUT entries. +# Otherwise the PWM duty cycle won't be configured correctly. emc.pwm_frequency = 14 # This divides the pwm frequency down to a smaller number