-
Notifications
You must be signed in to change notification settings - Fork 0
/
dds.S
392 lines (340 loc) · 15.7 KB
/
dds.S
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
;==========================================================
; DDS Generator for ATMega328p
;==========================================================
;
; Author: Tim Savage <[email protected]>
;
; DDS generation based on the work of Jesper Hansen
; http://www.qsl.net/zs1ayj/page10.htm
;
; Changes from his design:
; - Ported to ATMega328p
; - Replaced Serial comms with I2C (TWI)
; - Optimisation of having the wave buffer in SRAM to
; remove a clock cycle from DDS loop.
; - Additional waveform(s)
;
;==========================================================
.include "atmega328p.inc"
.include "twi_utils.asm"
;==========================================================
; Registers
;==========================================================
;
; These registers are used to generate DDS Output
#define Zero r1
#define Temp r16
#define ITemp r17
#define PhaseL r3
#define PhaseH r4
#define Value r5
#define Step0 r6
#define Step1 r7
#define Step2 r8
;==========================================================
; Definitions
;==========================================================
.equ WAVE_BUFFER, 0x0200
.equ TWI_ACK, (1<<TWINT) | (1<<TWEA) | (1<<TWEN) | (1<<TWIE)
.equ TWI_NACK, (1<<TWINT) | (0<<TWEA) | (1<<TWEN) | (1<<TWIE)
;==========================================================
; Macros
;==========================================================
; Load a wave table into the wave buffer (lo8 bits of loc must be 0)
.macro LOAD_TABLE loc
ldi ZH, hi8(\loc)
ldi ZL, lo8(\loc)
ldi XH, hi8(WAVE_BUFFER)
ldi XL, lo8(WAVE_BUFFER)
copy_loop\@:
lpm r0, Z+ ; Copy out of program memory
st X+, r0 ; Copy into data memory
cpi ZL, 0x00 ; Check if we have rolled over
brne copy_loop\@
.endm
; Clear Int and set control bits
.macro TWI_CTRL bits=(1<<TWEA)
ldi Temp, \bits | (1<<TWINT) | (1<<TWEN) | (1<<TWIE)
sts TWCR, Temp
.endm
;==========================================================
; Boot section - Jump table
;==========================================================
.text
.org 0x0000
__vectors:
jmp __ctors_end ; RESET_addr
jmp __bad_interrupt ; INT0_addr
jmp __bad_interrupt ; INT1_addr
jmp __bad_interrupt ; PCINT0_addr
jmp __bad_interrupt ; PCINT1_addr
jmp __bad_interrupt ; PCINT2_addr
jmp __bad_interrupt ; WDT_addr
jmp __bad_interrupt ; TIMER2_COMPA_addr
jmp __bad_interrupt ; TIMER2_COMPB_addr
jmp __bad_interrupt ; TIMER2_OVF_addr
jmp __bad_interrupt ; TIMER1_CAPT_addr
jmp __bad_interrupt ; TIMER1_COMPA_addr
jmp __bad_interrupt ; TIMER1_COMPB_addr
jmp __bad_interrupt ; TIMER1_OVF_addr
jmp __bad_interrupt ; TIMER0_COMPA_addr
jmp __bad_interrupt ; TIMER0_COMPB_addr
jmp __bad_interrupt ; TIMER0_OVF_addr
jmp __bad_interrupt ; SPI_STC_addr
jmp __bad_interrupt ; USART_RX_addr
jmp __bad_interrupt ; USART_UDRE_addr
jmp __bad_interrupt ; USART_TX_addr
jmp __bad_interrupt ; ADC_addr
jmp __bad_interrupt ; EE_READY_addr
jmp __bad_interrupt ; ANALOG_COMP_addr
jmp TWI ; TWI_addr
jmp __bad_interrupt ; SPM_READY_addr
;==========================================================
; Code
;==========================================================
__ctors_end:
; Stack pointer setup not required
; atmega328(p) defaults to RAMEND
clr Zero ; Zero register
rjmp MAIN
__bad_interrupt:
reti
MAIN:
cli ; Disable interrupts
; Setup Port D for DDS Output
ser Temp
out _DDRD, Temp ; Configure all for output
out _PORTD, Zero ; Clear the current output
; Configure I2C (TWI) interface
ldi Temp, (0x42<<1) ; Set address to 0x42
sts TWAR, Temp
TWI_CTRL (1<<TWEA)
; Setup some defaults
LOAD_TABLE sine_table
ldi Temp, 0xC5 ; Set a default frequency of 1Khz
mov Step0, Temp
ldi Temp, 0x20
mov Step1, Temp
ldi Temp, 0x00
mov Step2, Temp
rcall RESET_DDS
sei ; Enable interrupts
DDS_LOOP:
; Add step value
add PhaseL, Step0 ; (1 clock)
adc PhaseH, Step1 ; (1 clock)
adc YL, Step2 ; (1 clock)
; Load value from wave buffer
ld Value, Y ; (2 clocks)
; Write value to PORTD (use out as it only uses 1 clock)
out _PORTD, Value ; (1 clock)
; Check if DDS generation is still active
rjmp DDS_LOOP ; (2 clocks)
; (Total: 8)
; Reset DDS Counters and set wave buffer pointer to the start
RESET_DDS:
; Reset counters
clr Value
clr PhaseL
clr PhaseH
; Set wave buffer pointer to the start of the wave buffer
ldi YH, hi8(WAVE_BUFFER)
ldi YL, lo8(WAVE_BUFFER)
ret ; Return
; Load a DDS waveform (wave on r25)
DDS_LOAD:
ldi ZL, pm_lo8(load_table)
ldi ZH, pm_hi8(load_table)
add ZL, r25
adc ZH, Zero
ijmp
load_table: ; 4 Bits long
rjmp load_zero
rjmp load_sine
rjmp load_square
rjmp load_triangle
rjmp load_sawtooth
rjmp load_rsawtooth
rjmp load_zero
rjmp load_zero
rjmp load_zero
rjmp load_zero
rjmp load_zero
rjmp load_zero
rjmp load_zero
rjmp load_zero
rjmp load_zero
rjmp load_zero
load_zero:
LOAD_TABLE zero_table
ret
load_sine:
LOAD_TABLE sine_table
ret
load_square:
LOAD_TABLE square_table
ret
load_triangle:
LOAD_TABLE triangle_table
ret
load_sawtooth:
LOAD_TABLE sawtooth_table
ret
load_rsawtooth:
LOAD_TABLE rsawtooth_table
ret
; Handle a DDS command (command in r25)
DDS_COMMAND:
mov ITemp, r25 ; Get hi 4 bits (command)
andi ITemp, 0xF0
andi r25, 0x0F ; Get lo 4 bits (index)
cpi ITemp, 0x10 ; Load
brne dds_cmd1
rcall DDS_LOAD
ret
dds_cmd1:
cpi ITemp, 0x20 ; Frequency Up
brne dds_cmd2
ldi ZH, hi8(step_table)
ldi ZL, lo8(step_table)
add ZL, r25
lpm ITemp, Z
add Step0, ITemp
adc Step1, Zero
adc Step2, Zero
ret
dds_cmd2:
cpi ITemp, 0x30 ; Frequency Down
brne dds_cmd_default
ldi ZH, hi8(step_table)
ldi ZL, lo8(step_table)
add ZL, r25
lpm ITemp, Z
sub Step0, ITemp
sbc Step1, Zero
sbc Step2, Zero
ret
dds_cmd_default:
ret ; Return
TWI:
lds ITemp, TWSR ; Load from status register
andi ITemp, TW_STATUS_MASK ; Mask out pre-scaler bits
cpi ITemp, TW_SR_DATA_ACK
brne twi_default
; Data has been received in SR Mode
lds r25, TWDR ; Store data in r25
TWI_CTRL (1<<TWEA) ; Send Ack
rcall DDS_COMMAND
reti
twi_default:
TWI_CTRL (1<<TWEA)
twi_exit:
reti
;==========================================================
; Waveform tables
;==========================================================
.org 0x0200 ; Ensure alignment of tables is 0xXX00
zero_table: ; Aligned to center of the display
.byte 0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F,0x7F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4D,0x4A,0x47,0x44,0x41,0x3F,0x3C,0x39,0x37,0x34,0x32,0x2F,0x2D,0x2B,0x28
.byte 0x26,0x24,0x22,0x20,0x1E,0x1C,0x1A,0x18,0x16,0x15,0x13,0x11,0x10,0x0F,0x0D,0x0C
.byte 0x0B,0x0A,0x08,0x07,0x06,0x06,0x05,0x04,0x03,0x03,0x02,0x02,0x02,0x01,0x01,0x01
.byte 0x01,0x01,0x01,0x01,0x02,0x02,0x02,0x03,0x03,0x04,0x05,0x06,0x06,0x07,0x08,0x0A
.byte 0x0B,0x0C,0x0D,0x0F,0x10,0x11,0x13,0x15,0x16,0x18,0x1A,0x1C,0x1E,0x20,0x22,0x24
.byte 0x26,0x28,0x2B,0x2D,0x2F,0x32,0x34,0x37,0x39,0x3C,0x3F,0x41,0x44,0x47,0x4A,0x4D
.byte 0x4F,0x52,0x55,0x58,0x5B,0x5E,0x61,0x64,0x67,0x6A,0x6D,0x70,0x74,0x77,0x7A,0x7D
triangle_table:
.byte 0x7F,0x81,0x83,0x85,0x87,0x89,0x8B,0x8D,0x8F,0x91,0x93,0x95,0x97,0x99,0x9B,0x9D
.byte 0x9F,0xA1,0xA3,0xA5,0xA7,0xA9,0xAB,0xAD,0xAF,0xB1,0xB3,0xB5,0xB7,0xB9,0xBB,0xBD
.byte 0xBF,0xC1,0xC3,0xC5,0xC7,0xC9,0xCB,0xCD,0xCF,0xD1,0xD3,0xD5,0xD7,0xD9,0xDB,0xDD
.byte 0xDF,0xE1,0xE3,0xE5,0xE7,0xE9,0xEB,0xED,0xEF,0xF1,0xF3,0xF5,0xF7,0xF9,0xFB,0xFD
.byte 0xFF,0xFD,0xFB,0xF9,0xF7,0xF5,0xF3,0xF1,0xEF,0xED,0xEB,0xE9,0xE7,0xE5,0xE3,0xE1
.byte 0xDF,0xDD,0xDB,0xD9,0xD7,0xD5,0xD3,0xD1,0xCF,0xCD,0xCB,0xC9,0xC7,0xC5,0xC3,0xC1
.byte 0xBF,0xBD,0xBB,0xB9,0xB7,0xB5,0xB3,0xB1,0xAF,0xAD,0xAB,0xA9,0xA7,0xA5,0xA3,0xA1
.byte 0x9F,0x9D,0x9B,0x99,0x97,0x95,0x93,0x91,0x8F,0x8D,0x8B,0x89,0x87,0x85,0x83,0x81
.byte 0x7F,0x7D,0x7B,0x79,0x77,0x75,0x73,0x71,0x6F,0x6D,0x6B,0x69,0x67,0x65,0x63,0x61
.byte 0x5F,0x5D,0x5B,0x59,0x57,0x55,0x53,0x51,0x4F,0x4D,0x4B,0x49,0x47,0x45,0x43,0x41
.byte 0x3F,0x3D,0x3B,0x39,0x37,0x35,0x33,0x31,0x2F,0x2D,0x2B,0x29,0x27,0x25,0x23,0x21
.byte 0x1F,0x1D,0x1B,0x19,0x17,0x15,0x13,0x11,0x0F,0x0D,0x0B,0x09,0x07,0x05,0x03,0x01
.byte 0x00,0x01,0x03,0x05,0x07,0x09,0x0B,0x0D,0x0F,0x11,0x13,0x15,0x17,0x19,0x1B,0x1D
.byte 0x1F,0x21,0x23,0x25,0x27,0x29,0x2B,0x2D,0x2F,0x31,0x33,0x35,0x37,0x39,0x3B,0x3D
.byte 0x3F,0x41,0x43,0x45,0x47,0x49,0x4B,0x4D,0x4F,0x51,0x53,0x55,0x57,0x59,0x5B,0x5D
.byte 0x5F,0x61,0x63,0x65,0x67,0x69,0x6B,0x6D,0x6F,0x71,0x73,0x75,0x77,0x79,0x7B,0x7D
sawtooth_table:
.byte 0x7F,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E
.byte 0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E
.byte 0x9F,0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE
.byte 0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE
.byte 0xBF,0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE
.byte 0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE
.byte 0xDF,0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE
.byte 0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE
.byte 0xFF,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E
.byte 0x0F,0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E
.byte 0x1F,0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E
.byte 0x2F,0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E
.byte 0x3F,0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E
.byte 0x4F,0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E
.byte 0x5F,0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E
.byte 0x6F,0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E
rsawtooth_table:
.byte 0x7F,0x7E,0x7D,0x7C,0x7B,0x7A,0x79,0x78,0x77,0x76,0x75,0x74,0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,0x00,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
.byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
step_table:
.byte 0x00,0x01,0x0A,0x64,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00