Datasheet
www.ti.com
SOFTWARE
TLV5633C
TLV5633I
SLAS190C – MARCH 1999 – REVISED SEPTEMBER 2006
In the following example, the code generates a waveform at 20 KSPS with 32 samples stored in a table within
the program memory space of the microcontroller.
The waveform data is located in the program memory space at segment SINTBL beginning with the MSW of the
first 16-bit word (the 4 MSBs are ignored), followed by the LSW. Two bytes are required for each DAC word (the
table is not shown in the code example).
The program consists of two parts:
• A main routine, which is executed after reset and which initializes the timer and the interrupt system of the
microcontroller.
• An interrupt service routine, which reads a new value from the waveform table and writes it to the DAC.
;--------------------------------------------------------------------------------------
; File: WAVE.A51
; Function: wave generation with TLV5633
; Processors: 80C51 family (running at 12 MHz)
; Software: ASM51 assembler, Keil BL51 code-banking linker
;(C) 1999 Texas Instruments
;--------------------------------------------------------------------------------------
;--------------------------------------------------------------------------------------
; Program function declaration
;--------------------------------------------------------------------------------------
NAME WAVE
MAIN SEGMENT CODE
ISR SEGMENT CODE
WAVTBL SEGMENT CODE
VAR1 SEGMENT DATA
STACK SEGMENT IDATA
;--------------------------------------------------------------------------------------
; Code start at address 0, jump to start
;--------------------------------------------------------------------------------------
CSEG AT 0
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
; The signal to be output on the dac is stored in a table
; 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, #wavetable ; set DPTR to the start of the table
MOV R0, #001H ; R0 selects DAC MSW
MOV A,rolling_ptr ; ACC loaded with the pointer into the wave table
MOVC A,@A+DPTR ; get msb from the table
MOVX @R0, A ; write DAC MSW
MOV R0, #000H ; R0 selects DAC LSW
MOV A,rolling_ptr ; move rolling pointer back 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
MOVX @R0, A ; write DAC LSW
MOV A,rolling_ptr ; load ACC with rolling pointer again
INC A ; increment the ACC twice, to get next sample
INC A
ANL A,#003FH ; wrap back round to 0 if >64
MOV rolling_ptr,A ; move value held in ACC back to the rolling pointer
15
Submit Documentation Feedback