Datasheet
SLAS259B − DECEMBER 1999 − REVISED APRIL 2004
16
WWW.TI.COM
APPLICATION INFORMATION
LJMP start ; Execution starts at address 0 on power−up.
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
; Code in the timer0 interrupt vector
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
CSEG AT 0BH
LJMP timer0isr ; Jump vector for timer 0 interrupt is 000Bh
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
; Define program variables
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
RSEG VAR1
rolling_ptr: DS 1
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
; Interrupt service routine for timer 0 interrupts
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
RSEG ISR
timer0isr:
PUSH PSW
PUSH ACC
CLR T0 ; set CSB low
CLR T1 ; set FS low
; The signal to be output on the dac is a sine function. One cycle of a sine wave is
; held in a table @ sinevals as 32 samples of msb, lsb pairs (64 bytes). The pointer,
; rolling_ptr, rolls round the table of samples incrementing by 2 bytes (1 sample) on
; each interrupt (at the end of this routine).
MOV DPTR,#sinevals ; set DPTR to the start of the table of sine signal values
MOV A,rolling_ptr ; ACC loaded with the pointer into the sine table
MOVC A,@A+DPTR ; get msb from the table
ORL A, #00H ; set control bits
MOV SBUF,A ; send out msb of data word
MOV A,rolling_ptr ; move rolling pointer in to ACC
INC A ; increment ACC holding the rolling pointer
MOVC A,@A+DPTR ; which is the lsb of this sample, now in ACC
MSB_TX:
JNB TI, MSB_TX ; wait for transmit to complete
CLR TI ; clear for new transmit
MOV SBUF,A ; and send out the lsb
LSB_TX:
JNB TI, LSB_TX ; wait for lsb transmit to complete
SETB T1 ; set FS = 1
CLR TI ; clear for new transmit
MOV A,rolling_ptr ; load ACC with rolling pointer
INC A ; increment the ACC twice, to get next sample
INC A
ANL A,#03FH ; wrap back round to 0 if >64
MOV rolling_ptr,A ; move value held in ACC back to the rolling pointer
SETB T0 ; CSB high
POP ACC
POP PSW
RETI
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−
; Set up stack
;−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−