SHARE
TWEET

Untitled

a guest Jan 14th, 2013 13 Never
  1. DAC    EQU 0600h   ;DAC memory mapped at address 600h
  2. tbl_len EQU 24  ;length of sine wave table
  3.  
  4.     ORG 8100H       ;start of program
  5.  
  6. sine:   mov R7, #tbl_len    ;initialise table counter
  7.     mov R6, #0  ;initialise table pointer
  8.  
  9. sloop:  mov dptr, #table    ;load dptr with address of table
  10.     mov a, R6   ;load acc with table pointer
  11.     movc    a, @a+dptr  ;read from table + table pointer
  12.  
  13.     mov dptr, #DAC  ;load dptr with 0600 DAC base address
  14.     movx    @dptr, a    ;Output table value from DAC
  15.     acall   delay
  16.     inc R6  ;inc table pointer
  17.     djnz    R7, sloop   ;dec table counter until zero
  18.     sjmp  sine  ;Repeat loop
  19.  
  20. delay:  mov R0, #11
  21. loop:   djnz    R0, dloop   ;go around this loop 11 times
  22.     ret
  23.  
  24. table:  DB  1,5,18,38,65,95,128,161,192,218,238,251
  25.     DB  255,251,238,218,192,161,128,95,65,38,18,5
RAW Paste Data
Top