-
Notifications
You must be signed in to change notification settings - Fork 121
/
audio_pwm.pio
58 lines (54 loc) · 918 Bytes
/
audio_pwm.pio
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
;
; Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
;
; SPDX-License-Identifier: BSD-3-Clause
;
.program pwm_one_bit_dither
.side_set 1 opt
; Format:
; | high len | low len | (dither) * n |
; OSR level
; cycle length = 7 + 2 + 127
; 136 clocks/cycle frequency 352941 / 16 = 22058
delay:
nop [2]
.wrap_target
out pins, 1
loops:
mov x, isr side 1
loop1:
jmp x-- loop1
mov x, y side 0
loop0:
jmp x-- loop0
jmp !osre delay
public entry_point:
pull
out isr, 7
out y, 7
.wrap
.program pwm_two_bit_dither
.side_set 1 opt
; Format:
; | high len | low len | (dither) * n |
; OSR level
; this 138 clocks/cycle frequency 347826 / 16 = 21739Hz
delay:
nop [2]
.wrap_target
out pins, 1
out pins, 1
out pins, 1
loops:
mov x, isr side 1
loop1:
jmp x-- loop1
mov x, y side 0
loop0:
jmp x-- loop0
jmp !osre delay
entry_point:
pull
out isr, 7
out y, 7
.wrap