|
@@ -0,0 +1,157 @@
|
|
1
|
+# ATtiny85 I2C protocol
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+Arguments in curly braces are optional.
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+Function | Opcode | Arguments
|
|
8
|
+-------------------------|--------|---------------------------
|
|
9
|
+Set hold PWM duty cycle | 0 | (duty) { (freq) { (div) }}
|
|
10
|
+
|
|
11
|
+Arguments | Range | Default | Note
|
|
12
|
+----------|-------|---------|------------------------------------------------------
|
|
13
|
+(duty) | 0-255 | 127 | 0=0%, 255=100%
|
|
14
|
+(freq) | 0-255 | 255 | Sets PWM top value
|
|
15
|
+(div) | 1-15 | 5 | Set the PWM base clock frequency (See table below)
|
|
16
|
+
|
|
17
|
+PWM frequency and period for each possible (div) setting.
|
|
18
|
+
|
|
19
|
+Reg. | | Base |
|
|
20
|
+Value | Div | Frequency | Period
|
|
21
|
+------|------|-------------|-------
|
|
22
|
+ 1 | 1 | 16 M | 62.5 n
|
|
23
|
+ 2 | 2 | 8 M | 125 n
|
|
24
|
+ 3 | 4 | 4 M | 250 n
|
|
25
|
+ 4 | 8 | 2 M | 500 n
|
|
26
|
+ 5 | 16 | 1 M | 1 u
|
|
27
|
+ 6 | 32 | 500 K | 2 u
|
|
28
|
+ 7 | 64 | 250 K | 4 u
|
|
29
|
+ 8 | 128 | 125 K | 8 u
|
|
30
|
+ 9 | 256 | 62500 Hz | 16 u
|
|
31
|
+10 | 512 | 31250 Hz | 32 u
|
|
32
|
+11 | 1024 | 15625 Hz | 64 u
|
|
33
|
+12 | 2048 | 7812.5 Hz | 128 u
|
|
34
|
+13 | 4096 | 3906.25 Hz | 256 u
|
|
35
|
+14 | 8192 | 1953.125 Hz | 512 u
|
|
36
|
+15 |16384 | 976.6625 Hz | 1024 u
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+Function | Opcode | Arguments
|
|
40
|
+-------------------------|--------|---------------------------
|
|
41
|
+Note on velocity | 1 | (vel)
|
|
42
|
+
|
|
43
|
+Arguments | Range | Default | Note
|
|
44
|
+----------|-------|---------|------------------------------------------------------
|
|
45
|
+(vel) | 0-127 | n/a | Note on velocity.
|
|
46
|
+
|
|
47
|
+Execute a note onset.
|
|
48
|
+The (vel) value is translated to an attack pulse duration
|
|
49
|
+by looking up the pulse tick count in the velocity table.
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+Function | Opcode | Arguments
|
|
53
|
+-------------------------|--------|-------------------------------------------------
|
|
54
|
+Note on ticks | 2 | (pulse-ticks-high-byte) (pulse-ticks-low-byte)
|
|
55
|
+
|
|
56
|
+Execute a note onset.
|
|
57
|
+The 16 bit attack duration in ticks is calculated from microseconds.
|
|
58
|
+
|
|
59
|
+ pulse-ticks = (usec / 1e6) * (16e6/256)
|
|
60
|
+
|
|
61
|
+Where 16e6 is the system clock frequency and 256 is the timer0 clock divider.
|
|
62
|
+`TCCR0B:C02,C01,C00 = 100b (4)`
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+ticks to micoseconds:
|
|
66
|
+
|
|
67
|
+ usecs = (pulse-ticks * 1e6)*(256/16e6)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+Function | Opcode | Arguments
|
|
71
|
+-------------------------|--------|---------------------------
|
|
72
|
+Note off | 3 | None
|
|
73
|
+
|
|
74
|
+Turn off a sounding note by settting the hold-voltage to 0.
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+Function | Opcode | Arguments
|
|
78
|
+-------------------------|--------|---------------------------
|
|
79
|
+Set read address | 4 | (src) {(addr)}
|
|
80
|
+
|
|
81
|
+Set the source and address of the next I2C read request.
|
|
82
|
+
|
|
83
|
+The read can come from one of three memory banks:
|
|
84
|
+Register File, MIDI velocity table or EEPROM.
|
|
85
|
+See the _Memory Location Id_ table below for the (src) id values.
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+Arguments | Range | Default | Note
|
|
89
|
+------------|-------|---------|-------------------------------------------------------
|
|
90
|
+(src) | 0-2 | n/a | Memory location id. See _Memory Location Id_ table.
|
|
91
|
+(addr) | 0-255 | n/a | Offset from base address set by (src)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+Function | Opcode | Arguments
|
|
95
|
+-------------------------|--------|---------------------------
|
|
96
|
+Write memory | 5 |
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+Function | Opcode | Arguments
|
|
101
|
+-------------------------|--------|---------------------------
|
|
102
|
+Set hold delay | 6 | { high {low}}
|
|
103
|
+
|
|
104
|
+Set the length of the delay, in ticks, between when the attack pulse ends and when the
|
|
105
|
+hold voltage is applied.
|
|
106
|
+The high and low byte values are calculated identically to the
|
|
107
|
+attack pulse duration values.
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+Function | Opcode | Arguments
|
|
111
|
+-------------------------|--------|---------------------------
|
|
112
|
+Set flags variable | 7 | (flags)
|
|
113
|
+
|
|
114
|
+ 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
|
|
115
|
+-----|-----|-----|-----|-----|-----|-----|-----
|
|
116
|
+ n/a | n/a | n/a | n/a | n/a | n/a | n/a | HOA
|
|
117
|
+
|
|
118
|
+_HOA_ : Set to apply the hold voltage at the beginning of the attack.
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+Register file
|
|
122
|
+
|
|
123
|
+Address | Label | Note
|
|
124
|
+--------|-----------------|------------------------------------------------------------------------------------------------
|
|
125
|
+0 | Reg_Rd_Addr | Next register file address to read.
|
|
126
|
+1 | Table_Rd_Addr | Next MIDI velocity address to read.
|
|
127
|
+2 | EEPROM_Rd_Addr | Next EEPROM address to read.
|
|
128
|
+3 | Read_Src_Addr | Source of the next I2C read request. See Memory Location Id table below.
|
|
129
|
+4 | Reg_Wr_Addr | Next register file address to write.
|
|
130
|
+5 | Table_Rd_Addr | Next MIDI velocity address to write.
|
|
131
|
+6 | EEPROM_Rd_Addr | Next EEPROM address to write.
|
|
132
|
+7 | Write_Dst_Addr | Destination of the next 'write operation'. See Memory Location id table below.
|
|
133
|
+8 | Tmr_High_Addr | Current attack pulse tick count high byte
|
|
134
|
+9 | Tmr_Low_Addr | Current attack pulse tick count low byte
|
|
135
|
+10 | Tmr_Div_Addr | Attack pulse counter frequency divider.
|
|
136
|
+11 | Pwm_Duty_Addr | Duty cycle of the hold PWM generator
|
|
137
|
+12 | Pwm_Freq_Addr | PWM counter max values. Determines the PWM frequency.
|
|
138
|
+13 | Pwm_Div_Addr | PWM clock divider
|
|
139
|
+14 | State_Addr | Current solenoied state.
|
|
140
|
+15 | Error_Addr | Error status
|
|
141
|
+16 | Max_Tmr_Hi_Addr | Max attack pulse high byte tick count.
|
|
142
|
+17 | Delay_High_Addr | Hold delay onset tick count high byte
|
|
143
|
+18 | Delay_Low_Addr | Hold delay onset tick count low byte
|
|
144
|
+19 | Flags_Addr | Binary variable field.
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+Memory Location Id table.
|
|
148
|
+
|
|
149
|
+Id | Memory | Note
|
|
150
|
+---|----------------|-------------------------------
|
|
151
|
+ 0 | Register file | See register table file
|
|
152
|
+ 1 | Velocity table | MIDI velocity to pulse ticks lookup table
|
|
153
|
+ 2 | EEPROM | EEPROM data memory
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|