Skip to content

Commit 25f8694

Browse files
author
Thomas Preston
committed
Fixed issue #15 with pwm acting three times as fast.
1 parent 0120f44 commit 25f8694

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Change Log
22
==========
33

4+
v0.7.4
5+
------
6+
- Fixed a bug with io_pwm() running three times faster than it should.
7+
Fixes #15.
8+
49
v0.7.3
510
------
611
- Fixed a bug with colourtail timing issue in the firmware.

codebug_tether/core.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def pwm_on(self, t2_prescale, full_period, on_period):
170170
"""Turns on the PWM generator with the given settings.
171171
172172
:param t2_prescale: One of T2_PS_1_1, T2_PS_1_4, T2_PS_1_16
173-
Scales down the 4MHz instruction clock by
173+
Scales down the 12MHz instruction clock by
174174
1, 4 or 16.
175175
:param full_period: 8-bit value - which is scaled up to 10-bits
176176
(<< 2) - to which timer 2 will count up to
@@ -180,7 +180,7 @@ def pwm_on(self, t2_prescale, full_period, on_period):
180180
full_period to control duty cycle. For
181181
example:
182182
183-
# 4MHz / 16 with 50% duty cycle
183+
# 12MHz / 16 with 50% duty cycle
184184
codebug.pwm_on(T2_PS_1_16, 0xff, 0x200)
185185
186186
"""
@@ -203,14 +203,13 @@ def pwm_freq(self, frequency):
203203
204204
"""
205205
# calculate pwm settings
206-
# 4 MHz / 16 = 250k ticks per second
207-
full_period = int(250000 / frequency) - 1
206+
# 12MHz / 16 = 750k ticks per second
207+
full_period = int(750000 / frequency) - 1
208208
# for 50% duty cycle: shift up by 2 then /(2 i.e. 50% duty cycle)
209209
# on_period = (full_period << 2) / 2;
210210
# this is quicker
211211
on_period = full_period << 1
212212
self.pwm_on(T2_PS_1_16, full_period, on_period)
213-
pass
214213

215214
def pwm_off(self):
216215
go_busy_off_mask = 0xff ^ (1 << 4)

codebug_tether/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.7.3'
1+
__version__ = '0.7.4'

0 commit comments

Comments
 (0)