;wave1.asm ;Prototype of an arbitrary waveform generator ;Program memory is used to store the waveform table ;The program can be optimized by locating the waveform ;table in the interna; SRAM, accessing which takes only ;2 clock cycles (instead of 3 for program memory) ;SRAM is accessed with pointer auto increment feature ;that cuts the number of clock cycles taken in 1 loop ;by 1 clock cycle. The final optimized minimum state ;time would be 6 clock cycles instead of current 8 ;Dhananjay V. Gadre ;June 10, 1999 ;register contains the size of the wave table .def table_size=r20 .include "8515def.inc" .cseg .org 0 rjmp RESET ;Reset Handle rjmp RESET rjmp RESET rjmp RESET RESET: ldi r16, $A0 ;Init the Stack Pointer out SPL, r16 ldi r16, $0 OUT SPH, r16 ldi r16, 255 ;configure PORT B for all outputs out DDRB, r16 more: ldi table_size, 12 ;number of entries in the clock table ;init pointer to the waveform table ;table configured in Program Memory ldi ZH,high(WAVE_TABLE*2) ldi ZL,low(WAVE_TABLE*2);init Z-pointer loop_here: ;Clock Cycles lpm ;3 ;load from program memory out PORTB, r0 ;1 ;output to the port add ZL, r18 ;1 ;increment pointer to the table dec table_size ;1 ;decrement count brne loop_here ;2 ;loop ;Total=8 clock cycles rjmp more ;An arbitrary waveform table WAVE_TABLE: .db $A0, $A1 .db $B3, $B2 .db $32, $33 .db $35, $75 .db $f7, $95 .db $A7, $Af