Interfacing the TLV1562 Parallel ADĆConverter to the TMS320C54x DSP Application Report July 1999 Advanced Analog Products SLAA040
IMPORTANT NOTICE Texas Instruments and its subsidiaries (TI) reserve the right to make changes to their products or to discontinue any product or service without notice, and advise customers to obtain the latest version of relevant information to verify, before placing orders, that information being relied on is current and complete.
Contents 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 The Board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1 TMS320C54x Starter Kit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Contents 8.5.5 Dual Continuous Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.5.6 C-Callable With Mono Interrupt Driven Mode Using CSTART to Start Conversion . . . . . . . . . 8.6 Source Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.6.1 Common Software for all Modes (except C-Callable) . . . . . . . . . . . . . . . . .
Figures List of Figures 1 TLV1562 – DSP Interface of the EVM, Using RD or the CSTART Signal to Start Conversion . . . . . . . . . . . . . . . 2 2 TLV1562 – DSP Interface of the EVM, Using RD or the CSTART Signal to Start Conversion . . . . . . . . . . . . . . . 3 3 TLC5618 – DSP Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 4 TLC5651 – DSP Interface . . . . . . . . . . . . . . . . . . . . . . . .
vi SLAA040
Interfacing the TLV1562 Parallel ADC to the TMS320C54x DSP Falk Alicke and Perry Miller ABSTRACT In this application report we discuss the hardware and software interface of the TLV1562, 10-bit parallel-output analog-to-digital converter (ADC) to the TMS320C54x digital signal processor (DSP).
The Board 2.2 TLV1562EVM The TLV1562EVM gives customers an easy start with employing many of the features of this converter. A serial DAC (TLC5618A), a parallel DAC (THS5651), and the ADC (TLV1562) make this EVM flexible enough to test the features of the TLV1562. It also helps show how this ADC can be implemented. 2.3 ADC TLV1562 Overview The TLV1562 is a CMOS 10-bit high-speed programmable resolution analog-todigital converter, using a low-power recyclic architecture.
The Board 2.3.1.2 Simplification of Software Requirements Through Modified Interface Of all the TLV1562 modes of operation, only the mono interrupt driven mode uses the RD signal to start the conversion. This requires a very flexible handling of the read signal and therefore has to be performed by a general-purpose output signal. If the application excludes using the RD signal to start the conversion (using CSTART instead).
The Board This feature fits well into monitoring application. For example, the ADC may have to trigger on one event out of some channels inside an extremely small time window and then sample the correct channel with a higher resolution, but lower throughput to analyze this process. This feature also fits well into home security applications or applications that must monitor several inputs simultaneously. 2.3.
The Board Serial DAC DSP BCLKX SCLK BCLKR BFSX CS TLC5618A TMS320C542 BFSR BDX DIN BDR TLV1562 EVM Pin Connector Figure 3. TLC5618A to ’C542 DSP Interface 2.4.2 THS5651 – Parallel Output CommsDAC This 10-bit data converter has a parallel interface and is able to update its output with 100 MSPS. The two outputs on the 28-pin package can each drive a current between 2 mA and 20 mA with an output resistance >100 kΩ (ideal current source: output impedance → ∞).
Operational Overview 3 Operational Overview This chapter discusses the software and hardware interface for the TLV1562. Plus the overall operational sequence of the A/D interface is described. 3.1 Reference Voltage Inputs The voltage difference between the VREFP and VREFM terminals determines the analog input range, i.e., the upper and lower limits of the analog inputs that produce the full-scale (output data all 1s) and zero-scale (output data all 0s) readings, respectively.
Operational Overview 3.3 Connections Between the DSP and the EVM The following connections provide the interface between the DSP and the EVM: Table 1. Signal Connections DSP Signal Connector/Pin on the DSKplus circuit board Connector/Pin on the TLV1562EVM ADC Signal GND Connector JP4: Pin 1, 10, 11, 12, 14, 15, 19, 20, 21, 27, 34, 35 Connector JP5: Pin 6, 10, 11, 12 J10/2,J10/4,...,J10/34 GND J11/4,J11/6,...
Operational Overview 3.3.1 Jumpers Used on the TLV1562EVM Table 2.
The Serial DAC/DSP System 4 The Serial DAC/DSP System The software configures the buffered DSP serial port to the 16-bit master mode so that the DSP generates the frame sync signal at BFSX and the data clock at BCLKX serial port terminals. Table 4 shows the connections between the DSP and the DAC TLC5618A. Table 4.
The DSP Serial Port 5 The DSP Serial Port The buffered serial port provides direct communication with serial I/O devices and consists of six basic signals and five registers. The DSP internal serial port operation section discusses the registers. The six signals are: • BCLKX - The serial transmit clock. This signal clocks the transmitted data from the BDX terminal to the DIN terminal of the TLC5618A. • BCLKR - The serial receive clock. This signal clocks data into the DSP BDR terminal.
Other DSP/TLV1562 Signals 6 Other DSP/TLV1562 Signals These paragraphs describe other DSP and TLV1562 signals. 6.1 DSP Internal Serial Port Operation Three signals are necessary to connect the transmit pins of the transmitting device with the receive pins of the receiving device for data transmission. The transmitted serial data signal (BDX) sends the actual data. BFSX initiates the transfer (at the beginning of the packet), and BCLKX clocks the bit transfer.
Conversation Between the TLV1562 and the DSP 7 Conversation Between the TLV1562 and the DSP The complexity of the TLV1562 ADC may be confusing because of the number of possible modes to drive the protocol between DSP and ADC. The following paragraphs explain more about the data sheet descriptions for interfacing the ’C54x to the ADC. 7.1 Writing to the ADC Registers CR0 and CR1 must be set to choose any of the modes the TLV1562 offers.
Conversation Between the TLV1562 and the DSP Table 7. DSP Algorithm for Mono Interrupt Driven Mode Using RD Wait cycles for the DSP internally (40 MHz DSPCLK): STEPS 0. TIMING, NOTES APD=0 ADCSYCLK = 7.5 MHz APD=0 ADCSYCLK = 10 MHz APD=1 ADCSYCLK = 10 MHz APD=1 ADCSYCLK = 10 MHz ≥6 ≥5 ≥26 ≥25 Initialization Write all configuration data to the ADC activate the mono interrupt-driven mode in CR0(2;3) 1. set CS deselect ADC (optional with APD=0) 2.
Conversation Between the TLV1562 and the DSP 7.3 Mono Interrupt Driven Mode Using CSTART Use the CSTART signal when two or more ADCs must sample/convert signals at the same time. Instead of the RD signal, the timing for sampling and converting is started with the edges of the CSTART signal. The RD signal is still required to get the data out of the ADC and onto the bus. Table 8. DSP Algorithm for Mono Interrupt Driven Mode Using CSTART Wait cycles for the DSP internally (40MHz DSPCLK): APD=0 ADCSYCLK = 7.
Conversation Between the TLV1562 and the DSP 7.4 Dual Interrupt Driven Mode Using techniques similar to those described in the first two modes for sampling/converting/sending tasks, the dual mode samples two channels at the same time and sends out the results in series to the data port. The CSTART pin is used to start sampling and converting. Table 9. DSP Algorithm for Dual Interrupt Driven Mode Wait cycles for the DSP internally (40MHz DSPCLK): APD=0 ADCSYCLK = 7.
Conversation Between the TLV1562 and the DSP 7.5 Mono Continuous Mode This mode simplifies data acquisition, since there is no need to generate a signal to sample or convert data. Instead, initializing this mode once, the ADC sends out the data continuously and will be read by the DSP with the RD signal. CAUTION: In this mode, the sampling result sent out by the ADC is the value of the sample from the last cycle. Therefore, the first sample after initialization is trash. Table 10.
Conversation Between the TLV1562 and the DSP 7.6 Dual Continuous Mode The dual continuous mode provides a data stream of two input signals. The characteristic of the data protocol is similar to the mono continuous mode but with the use of two RD cycles for one sample/hold cycle. CAUTION: In this mode, the sampling result sent out by the ADC is the value of the sample from the last cycle. Therefore, the first sample after initialization is trash. Table 11.
Software Overview 8 Software Overview The software in this report shows how to use all modes of the TLV1562 and useful variations for each mode. It also includes a C program to start data acquisition from a C level. To limit the number of programs, the report supplies five files for running the ADC in five modes; a sixth program shows the C-callable function. Each program can enable different software blocks to give the user a large choice for generating the data acquisition.
Software Overview 0000h (OVLY = 1) 007Fh 0080h 00FFh 0100h 017Fh 0180h Original Interrupts DSKplus Starter Kit Communication Kernel Starter Kit RAM 07FFh 0800h 0FFFh 1000h Unused 01FFh 0200h Software Interrupt Table 027Fh 0280h BSP RAM Block or Program RAM Unused 02FFh 0300h Kernel Buffer (10 Words) Linked Program Memory Code 1009h 100Ah HPI RAM Block or Porgram RAM 17FFh 1800h Program 27FFh 2800h External EFFFh F000h On-Chip ROM F7FFh F800h ROM (Bootloader) FF7Fh FF80h ROM Interrupts FFFFh Reserved
Software Overview 8.3 Programming Strategies for the ’C54x, Explanations Before listing the program code, this chapter introduces some basic instructions (strategies) to provide the ’C54x user with some ideas for dealing with the DSP architecture. 8.3.1 Optimizing CPU Resources for Maximum Data Rates The ’C54x processor on the DSKplus starter kit runs at an internal clock frequency of 40 MHz.
Software Overview The timer output pin TOUT can be used to generate an output function with a prescale from half the CLK frequency down to 1FFFF. The problem: the high-time is always one clock cycle and only the low time of the TOUT signal changes with the timer. 8.3.
Software Overview 8.3.7 Interrupt Latency The time required to execute an interrupt depends on the handling of the IRQ at the four-word vector address or jumping further with a GOTO instruction.
Software Overview 8.3.9 Enabling Software Modules (.if/.elseif/.endif) To test different software solutions while keeping the number of files small requires integrating all the modules in the same file. Furthermore, a switch is needed to enable any of the software modules. Setting the constant SWITCH in the program header to either one or zero enables/disables the instructions inside an .IF-.ENDIF loop. Example: SWITCH1 SWITCH2 ... .set .set 00001h 00000h .
Software Overview 8.4.1.1 Software Polling The status of the input pin is tested in a loop until the valid transition occurs. After this transition, the program branches to the next instruction (reads data sample). Advantage: • Relatively fast program response after high-to-low transition of INT • The software compensates for variations of timing given in data sheets for conversion and the real time until the flag goes high. • Not critical for any software changes (e.g.
Software Overview 8.4.1.3 Interrupt Driven Solution Usually, the most elegant solution is to use an interrupt procedure to control external signals. The problem for this application is the high speed. First, if more than a few words of code have to be executed between two samples, the software has to ensure that the first interrupts will be completed before the second interrupt is enabled. This can be done by globally disabling IRQs while executing one IRQ. The second problem is the interrupt latency.
Software Overview Table 12. Switch Settings SWITCH DESCRIBTION SAVE_INTO_MEMORY Store the samples into DSP memory (location defined in constants.
Software Overview Task 1.2: Use channel B in differential input mode and an external clock source. Following changes have to be done with the set-up of Task 1.1: Table 14. Instruction in the Program Header (Step 1) R10BIT_RESOLUT .set 00001h ; enable 10-bit resolution R8BIT_RESOLUT .set 00000h R4BIT_RESOLUT .set 00000h INTERNAL_CLOCK .set 00000h EXTERNAL_CLOCK .set 00001h ; use external clock AUTO_PWDN_ENABLE .set 00000h ; disable auto power down DIFF_INPUT_MODE .
Software Overview Program Files: MONOIDM1.ASM includes the complete software algorithm to control the monomode CONSTANT.ASM common file of all modes (constants definition) VECTORS.ASM common file of all modes (IRQ vector table) Other Files: linker.cmd organization of the DSP memory (data and program memory) auto.bat batch file to start the compiler for the monomode software asm500.exe C54x Code compiler lnk500.
Software Overview Start 1 Initialize DSP Wait States, AR Pointer, IRQ Table, Data Memory, Serial Port No H/L Transition on INTO ? Initialize SPI Active Transmitter, Use Frame Sync, Generate External Clock SAVE_INTO_MEMORY = 1 Yes SAVE_INTO_MEMORY = 0 INTO (External Interrupt) Save Modified Register of The IRQ Routine, if Not Automatically Saved by The DSP (Not Required) Initialize DSP Memory For Sample Store AR7 Points to The First Store Location AR0 Points to The Table End ADCOUNT = Table Size (Numbe
Software Overview 8.5.2 Mono Interrupt Driven Mode Using CSTART to Start Conversion The following descriptions explain the software for the data acquisition in monomode using the CSTART signal. The required interface connections are shown in Figure 1. Program Files: MONOCST1.ASM Includes the complete software algorithm to control the monomode CALIBRAT.ASM Calibration procedure of the DAC CONSTANT.ASM Common file of all modes (constants definition) VECTORS.
Software Overview Start 1 Initialize DSP Wait States, AR Pointer, IRQ Table, Data Memory, Serial Port No H/L Transition on INTO ? Initialize SPI Active Transmitter, Use Frame Sync, Generate External Clock Yes SAVE_INTO_MEMORY = 1 INTO (External Interrupt) SAVE_INTO_MEMORY = 0 Save Modified Register of The IRQ Routine, if Not Automatically Saved by The DSP (Not Required) Initialize DSP Memory For Sample Store AR7 Points to The First Store Location AR0 Points to The Table End ADCOUNT = Table Size (Numb
Software Overview 8.5.2.1 Throughput Optimization† According to the data sheet, the mono interrupt driven mode with CSTART starting the conversion can be described as follows: After the conversion is done (INT set low), the DSP • selects the converter, • brings down the RD signal, • waits until the data are valid, • reads the data from the ADC and • resets RD to a high signal level. • Now, CSTART can be pulled low, for at least 100 ns, and set high to start a new conversion.
Software Overview CSTART RD 825 ns = 1.2 MPS Throughput CS INT Figure 8. Time Optimization (monocst1) Maximum Performance at 1.2 MSPS with Internal Clock 8.5.3 Dual Interrupt Driven Mode The following descriptions explain the software for the data acquisition in Dual Interrupt Driven Mode (using the CSTART signal). The required interface connections are shown in Figure 2. Program Files: DUALIRQ1.ASM Includes the complete software algorithm to control the Dual IRQ Driven Mode CALIBRAT.
Software Overview IMPORTANT NOTE: The code has been optimized to maximize the data throughput. It was found that CSTART can be pulled low earlier than the data read instruction is performed by the DSP. This saves the 100-ns wait time in STEP 3 because the data read requires at least 100 ns. Therefore, CSTART gets pulled high directly after data read, and the interface becomes faster and gains throughput. This variation will be found in the code.
Software Overview Start 1 Initialize DSP Wait States, AR Pointer, IRQ Table, Data Memory, Serial Port No H/L Transition on INTO ? Initialize SPI Active Transmitter, Use Frame Sync, Generate External Clock Yes SAVE_INTO_MEMORY = 1 INTO (External Interrupt) SAVE_INTO_MEMORY = 0 Save Modified Register of The IRQ Routine, if Not Automatically Saved by The DSP (Not Required) Initialize DSP Memory For Sample Store AR7 Points to The First Store Location AR0 Points to The Table End ADCOUNT = Table Size (Numb
Software Overview 8.5.4 Mono Continuous Mode The following descriptions explain the software for the data acquisition in Mono Continuous Mode. The required interface connections are shown in Figure 2 Program Files: MONOCON1.ASM Includes the complete software algorithm to control the Mono Continuous Mode CALIBRAT.ASM Calibration procedure of the DAC CONSTANT.ASM Common file of all modes (constants definition) VECTORS.ASM Common file of all modes (IRQ vector table) Other Files: linker.
Software Overview Start Initialize DSP Wait States, AR Pointer, IRQ Table, Data Memory, Serial Port Initialize SPI Active Transmitter, Use Frame Sync, Generate External Clock SAVE_INTO_MEMORY = 1 SAVE_INTO_MEMORY = 0 Initialize DSP Memory For Sample Store AR7 Points to The First Store Location AR0 Points to The Table End ADCOUNT = Table Size (Number of Samples) IME CALABRATION = 1 IME CALABRATION = 0 Calibrate Internal Midscale Error SME CALABRATION = 1 Calibrate System Midscale Error SME CALABRATION
Software Overview 8.5.5 Dual Continuous Mode The following descriptions explain the software for data acquisition in dual continuous mode. The required interface connections are shown in Figure 2. Program Files: DUALCON1.ASM Includes the complete software algorithm to control the Dual Continuous Mode CALIBRAT.ASM Calibration procedure of the DAC CONSTANT.ASM Common file of all modes (constants definition) VECTORS.ASM Common file of all modes (IRQ vector table) Other Files: linker.
Software Overview Start Initialize DSP Wait States, AR Pointer, IRQ Table, Data Memory, Serial Port Initialize SPI Active Transmitter, Use Frame Sync, Generate External Clock SAVE_INTO_MEMORY = 1 SAVE_INTO_MEMORY = 0 Initialize DSP Memory For Storing Samples AR7 Points to The First Store Location AR0 Points to The Table End ADCOUNT = Table Size (Number of Samples) IME CALABRATION = 1 IME CALABRATION = 0 Calibrate Internal Midscale Error SME CALABRATION = 1 Calibrate System Midscale Error SME CALABRAT
Software Overview 8.5.6 C-Callable with Mono Interrupt Driven Mode Using CSTART to Start Conversion The following descriptions explain the software for the data acquisition with a user friendly C program interface in monomode using the CSTART signal. The required interface connections are shown in Figure 2. Program Files: C1562.ASM Includes the complete software in the C-layer asm1562.ASM Includes the complete software algorithm to control the monomode CONSTANT.
Software Overview 8.6 Source Code The following paragraphs contain the source code. 8.6.1 Common Software for all Modes (except C-Callable) The files shown below contained the actual ’C54x program listings and program examples. 8.6.1.1 Constants.asm *************************************************************************** * TITLE : TLV1562 ADC Interface routine * * FILE : CONSTANT.
Software Overview NO_CALIB_OP .set 000C0h ; Operate without calibrated inputs (no offset) * INDEX MODE 1: NO_SW_PWDN SW_PWDN .set 00100h ; Software power down mode disabled .set 00101h ; instruction for software power down NO_AUTO_PWDN .set 00100h ; Automatic internal power–down Disabled AUTO_PWDN .set 00102h ; Automatic internal power–down Enabled TWO_COMPLEMENT .set 00100h ; ADC output in 2s complement format NO_2COMPLEMENT .set 00104h ; ADC output is binary, not in 2s complement NO_DEBUG .
Software Overview 8.6.1.2 Interrupt Vectors ************************************************************************** * TITLE : TLV1562 ADC Interface routine * * FILE : VECTORS.ASM * * FUNCTION : N/A * * PROTOTYPE : N/A * * CALLS : N/A * * PRECONDITION : N/A * * POSTCONDITION : N/A * * SPECIAL COND.
Software Overview nop nop nop tint return_enable ;4C; internal timer interrupt nop nop nop brint return_enable ;50; BSP receive interrupt nop nop nop bxint goto BXINT0 ;54; BSP transmit interrupt nop nop trint goto trint ;58; TDM receive interrupt nop nop txint return_enable ;5C; TDM transmit interrupt nop nop nop int3 return_enable ;60; external interrupt int3 nop nop nop hpiint goto hpiint ;64; HPIint * DO NOT MODIFY IF USING DEBUGGER * nop nop .
Software Overview 8.6.1.3 linker,cmd The linker file for each mode is specified with called file names, but in general looks like the following, made for the Mono Continuous Mode: /******************************************************************/ /* File: Linker.lnk COMMAND FILE */ /* */ .title ”COMMAND FILE FOR TLV1562.
Software Overview 8.6.2 Mono Mode Interrupt Driven Software Using RD to Start Conversion Mainprogram (Monomode.asm) ************************************************************************** * TITLE : TLV1562 ADC Interface routine * * FILE : MONOIDM1.ASM * * FUNCTION : MAIN * * PROTOTYPE : void MAIN () * * CALLS : SERIAL_DAC_INI() initialzation of the BSPI/serial DAC * * PRECONDITION : N/A * * POSTCONDITION : N/A * * SPECIAL COND.
Software Overview CR0_SEND .usect ”.variabl”, 1 ; sent value to register CR0 of the ADC CR1_SEND .usect ”.variabl”, 1 ; sent value to register CR1 of the ADC ZERO .usect ”.variabl”, 1 ; the value zero to send a ”Zero Dummy” ADSAMPLE .usect ”.variabl”, 1 ; last read sample from the ADC * TLC5618 conversation SERIAL_SEND .usect ”.variabl”, 1 ; serial output send word .usect ”.
Software Overview * initialize waitstates: DP = #00000h ; point to page zero @SWWSR = #01000h ; one I/O wait states * copy interrupt routine, which are not critical for the EVM to the IRQ table location: * this is required for the DSKplus kit but has to be changed on other platforms DP = #1 AR7 ; point to page 1 (IRQ vector table) = #00200h repeat(#3h) data(0084h) = *AR7+ AR7 ; copy the NMI vector = #00240h repeat(#35) ; copy INT0, INT1,...
Software Overview * reset pending IRQs IFR = #1 ; reset any old interrupt on pin INT0 .endif .if INT0_DRIVEN * enable Interrupt INT0 @IMR |= #01 ; allow INT0 .
Software Overview .if (AUTO_PWDN_ENABLE) @CR1_SEND ^= #NO_AUTO_PWDN ; clear NO_AUTO_PWDN bit if one @CR1_SEND |= #AUTO_PWDN ; set AUTO_PWDN mode .endif .if (DIFF_INPUT_MODE) @CR0_SEND ^= #SINGLE_END ; clear single ended input bit if one @CR0_SEND |= #DIFFERENTIAL ; set differential input mode .
Software Overview .elseif NO_INT0_SIG * instead of using the INT signal, the processor waits * for 6ADCSYSCLK+49ns and reads then the sample repeat(#32) nop ; wait for 34 processor cycles .endif * read sample STEP7: @ADSAMPLE = port(ADC) XF = 1 ; read the new sample into the DSP ; set RD .if (SEND_OUT_PARALLEL) * store sample into the parallel buffer location if choosen port(DAC1) = @ADSAMPLE ; update DAC output @TEMP ; activate ADC CS again = port(ADC) .endif .
Software Overview DP = #00000h ; point to page zero TC = bitf(@SPC,#01000h) ; test, is the XRDY Bit in SPC=1? if (TC) goto SEND_SERIAL_END ; don’t send something until XDR is empty ; this has been included because the serial DAC TLC5618A is not able to understand ; endless data-streem (the CS should not become high before end of sending ; the 16th bit) DP = #AD_DP ; reset Data page pointer to variables A = @ADSAMPLE<<2 ; leftshift of the sample for a 12-bit format @ADSAMPLE = A ; @ADSAMPLE |
Software Overview 8.6.3 Calibration of the ADC CALIBRAT.ASM ************************************************************************** * TITLE : TLV1562 ADC Interface routine * * FILE : CALIBRAT.ASM * * FUNCTION : CALIBRAT_INTERNAL_MID_SCALE * CALIBRAT_SYSTEM_MID_SCALE * * * CALLS : N/A * * PRECONDITION : N/A * * POSTCONDITION : N/A * * SPECIAL COND.
Software Overview * clear mode related bits in CR0 and set MONO_INT: @CR0_SEND &= #(MONO_INT^0FFFFh) ; clear bit for no calibration use @CR0_SEND &= #(DUAL_INT^0FFFFh) ; clear bit for no calibration use @CR0_SEND &= #(MONO_CONTINUOUS^0FFFFh); clear bit for no calibration use @CR0_SEND &= #(DUAL_CONTINUOUS^0FFFFh); clear bit for no calibration use @CR0_SEND |= #MONO_INT ; set calibration for further use * clear clock related bits in CR0 and set internal clock mode: @CR0_SEND &= #(CLK_INTERNAL^0FFFFh)
Software Overview nop ; wait for 34 cycles until conversion has been finished @TEMP = port(ADC) IFR = #1 ; read the sample but don’t care about the content ; reset any old interrupt on pin INT0 ********************************* * set back ADC register CR0/CR1 ********************************* * write CR1 (to reset old CSTART mode initialization, because otherwise, the ADC never resets * the INT pin to show a sample is available: @CR_PROBLEM = #(SW_PWDN|NO_AUTO_PWDN|NO_2COMPLEMENT|NO_DEBUG|RES_10_BIT|
Software Overview * use calibrated mode in the following for conversion @CR0_SEND |= #CALIB_OP ; set calibration for further use * clear mode related bits in CR_CALIBRA and set MONO_INT: @CR_CALIBRA &= #(MONO_INT^0FFFFh) ; clear bit for no calibration use @CR_CALIBRA &= #(DUAL_INT^0FFFFh) ; clear bit for no calibration use @CR_CALIBRA &= #(MONO_CONTINUOUS^0FFFFh); clear bit for no calibration use @CR_CALIBRA &= #(DUAL_CONTINUOUS^0FFFFh); clear bit for no calibration use @CR_CALIBRA |= #MONO_INT ; set
Software Overview nop ; wait for some sampling time XF = 1 ; reset CSTART repeat(#34) nop ; wait for 34 cycles until conversion has been finished @TEMP = port(ADC) IFR = #1 ; read the sample but don’t care about the content ; reset any old interrupt on pin INT0 ********************************* * set back ADC register CR0/CR1 ********************************* * write CR1 (to reset old CSTART mode initialization, because otherwise, the ADC never sets * back its int– pin to show a sample is availa
Software Overview 8.6.4 Mono Mode Interrupt Driven Software Using CSTART to Start Conversion Mainprogram (Monomode.asm) ************************************************************************** * TITLE : TLV1562 ADC Interface routine * * FILE : MONOCST1.ASM * * FUNCTION : MAIN * * PROTOTYPE : void MAIN () * * CALLS : N/A * * PRECONDITION : N/A * * POSTCONDITION : N/A * * SPECIAL COND.
Software Overview ADCOUNT ADMEM .usect ”.variabl”, 1 .usect ”.variabl”, 1 ; counter for one channel ; points to act. memory save location CR0_SEND .usect ”.variabl”, 1 ; sent value to register CR0 of the ADC CR1_SEND .usect ”.variabl”, 1 ; sent value to register CR1 of the ADC CR_PROBLEM .usect ”.variabl”, 1 ; problem with initialization of this mode ; when repeated (reset) ZERO .usect ”.variabl”, 1 ; the value zero to send a ”Zero Dummy” ADSAMPLE .usect ”.
Software Overview _MAIN: START: INITIALIZATION: * disable IRQ, sign extension mode, ini Stack INTM = 1 SXM ; SP ; disable IRQ = 0 ; no sign extension mode = #0280h ; initialize Stack pointer * initialize waitstates: DP = #00000h @SWWSR = #01000h ; point to page zero ; one I/O wait states * copy interrupt routine, which are not critical for the EVM to the IRQ table location: * this is required for the DSKplus kit but has to be changed on other platforms DP AR7 = #1 ; point to page 1 (IRQ vecto
Software Overview SERIAL_DAC_INI: BSPI_INI: DP = #0 @BSPC = #00038h ; reset SPI @BSPCE = #00101h ; set clock speed, no Autobuffer Mode @BSPC = #0C078h ; start serial port .endif .if (INT0_DRIVEN|POLLING_DRV) * reset pending IRQs IFR = #1 ; reset any old interrupt on pin INT0 .endif .if INT0_DRIVEN * enable Interrupt INT0 DP = #0 @IMR |= #01 ; allow INT0 .
Software Overview .elseif (R4BIT_RESOLUT) @CR1_SEND ^= #RES_10_BIT ; clear bit for 10–Bit Resolution @CR1_SEND |= #RES_4_BIT ; set 8–Bit conversion mode .endif .if (EXTERNAL_CLOCK) @CR0_SEND ^= #CLK_INTERNAL ; clear CLK_INTERNAL bit if one @CR0_SEND |= #CLK_EXTERNAL ; set CLK_EXTERNAL mode .endif .if (AUTO_PWDN_ENABLE) @CR1_SEND ^= #NO_AUTO_PWDN ; clear NO_AUTO_PWDN bit if one @CR1_SEND |= #AUTO_PWDN ; set AUTO_PWDN mode .endif .
Software Overview * write CR0 port(ADC) = @CR0_SEND ; send CR0 value to the ADC port(DEACTIVE) = @ZERO ; deselect ADC (CS high) NOP ; wait for tW(CSH)=50ns ******************************************* * ADC_mono_IRQ_Start: * read samples and store them into memory ******************************************* ADC_mono_IRQ_Start: ISTEP2: XF = 0 ; clear CSTART ISTEP3: NOP NOP NOP ; wait for TW(CSTARTL) ISTEP4: XF = 1 ; set CSTART STEP5: .
Software Overview STEP4: XF = 1 call STORE ; wait for TW(CSTARTL) and set CSTART ; store the last sample into the table .if INT0_DRIVEN return ; return from routine back to IRQ_INT0 .else goto STEP5 ; go back to receive next sample .endif ********************************** * STORE: * saving the samples into memory ********************************** STORE: .if (SEND_OUT_PARALLEL) * store sample into the parallel buffer location if choosen port(DAC1) = @ADSAMPLE ; update DAC output .endif .
Software Overview AR7 = #(data_loc_A) ; point to first date location of the storage table .
Software Overview Constants definition – see 8.6.1.1 Constants.asm Interrupt Routine handler – see 8.6.1.2 Interrupt Vectors 8.6.5 Dual Interrupt Driven Mode Mainprogram (DUALIRQ1.asm) ************************************************************************** * TITLE : TLV1562 ADC Interface routine * * FILE : DUALIRQ1.
Software Overview CR0_SEND .usect ”.variabl”, 1 ; the last value, sent to register CR0 CR1_SEND .usect ”.variabl”, 1 ; the last value, sent to register CR1 CR_PROBLEM .usect ”.variabl”, 1 ; problem with initialization of this mode when repeated (reset) ZERO .usect ”.variabl”, 1 ; the value zero to send TEMP .usect ”.variabl”, 1 ; temporary variable isr_save .usect ”.variabl”, 1 ; memory location to save AR7 during ; interrupts CH1_ADSAMPLE .usect ”.
Software Overview ; INTM = 1 ; disable IRQ SXM = 0 ; no sign extension mode = #0280h ; initialize Stack pointer SP * initialize waitstates: DP = #00000h ; point to page zero @SWWSR = #01000h ; one I/O wait states * copy interrupt routine, which are uncritical by the EVM to the IRQ table location: * this is required for the DSKplus kit but has to be changed on other platforms DP = #1 AR7 ; point to page 1 (IRQ vector table) = #00200h repeat(#3h) data(0084h) = *AR7+ AR7 ; copy the NMI ve
Software Overview @BSPCE = #00101h ; set clock speed, no Autobuffer Mode @BSPC = #0C078h ; start serial port .endif .if (INT0_DRIVEN|POLLING_DRV) * reset pending IRQs IFR = #1 ; reset any old interrupt on pin INT0 .endif .if INT0_DRIVEN * enable Interrupt INT0 DP = #0 @IMR |= #01 ; allow INT0 .
Software Overview .if (EXTERNAL_CLOCK) @CR0_SEND ^= #CLK_INTERNAL ; clear CLK_INTERNAL bit if one @CR0_SEND |= #CLK_EXTERNAL ; set CLK_EXTERNAL mode .endif .if (AUTO_PWDN_ENABLE) @CR1_SEND ^= #NO_AUTO_PWDN ; clear NO_AUTO_PWDN bit if one @CR1_SEND |= #AUTO_PWDN ; set AUTO_PWDN mode .endif .if (DIFF_INPUT_MODE) @CR0_SEND ^= #SINGLE_END ; clear single ended input bit if one @CR0_SEND |= #DIFFERENTIAL ; set differential input mode .
Software Overview port(DEACTIVE) = @ZERO ; deselect ADC (CS high) NOP ; wait for tW(CSH)=50ns * write CR0 port(ADC) = @CR0_SEND STEP1: port(DEACTIVE) = @ZERO NOP ; send CR0 value to the ADC ; deselect ADC (CS high) ; ******************************************* * ADC_dual_IRQ_Start: * read samples and store them into memory ******************************************* ADC_dual_IRQ_Start: ISTEP2: XF = 0 ; clear CSTART ISTEP3: NOP NOP NOP ; wait for TW(CSTARTL) .
Software Overview * read sample STEP2: XF = 0 ; clear CSTART STEP10: @CH1_ADSAMPLE = port(ADC) ; read the new sample into the DSP STEP14: @CH2_ADSAMPLE = port(ADC) ; read the new sample into the DSP STEP3: ; wait for TW(CSTARTL) .if (AUTO_PWDN_ENABLE) * wait 800ns before finishing the sampling (requirment in Auto power down mode) repeat(#38) nop ; wait for 40 clock cycles [t(APDR)=1000ns] .
Software Overview @ADSAMPLE |= #(TLC5618_LATCH_A|TLC5618_FAST_MODE|TLC5618_POWER_UP) ; set the mode of the DAC data(BDXR) = @ADSAMPLE ; send out the sample to the serial DAC SEND_SERIAL_END: .endif * test for table end, set pointer back if true .
Software Overview Constants definition – see 8.6.1.1 Constants.asm Interrupt Routine handler – see 8.6.1.2 Interrupt Vectors 8.6.6 Mono Continuous Mode Mainprogram (MONOCON1.asm) ************************************************************************** * TITLE : TLV1562 ADC Interface routine * * FILE : MONOCON1.
Software Overview isr_save .usect ”.variabl”, 1 ; memory location to save AR7 during ; interrupts ADSAMPLE .usect ”.variabl”, 1 ; last read sample from the ADC * Address Decoder constants: ADC .set 00002h ; activate A0 when TLV1562 is choosen RD_CALIBRATION .set 00001h ; activate A1 when CSTART is choosen DAC1 .set 00003h ; activate A2 when DAC1 is choosen DEACTIVE .set 00000h ; deactivate the address lines A0, A1 and A2 SAVE_INTO_MEMORY .
Software Overview data(data_loc_A) = @TEMP ; fill memory table 1 repeat(#num_data_B–1) data(data_loc_B) = @TEMP ; fill memory table 2 repeat(#num_data_C–1) data(data_loc_C) = @TEMP ; fill memory table 3 repeat(#num_data_D–1) data(data_loc_D) = @TEMP ; fill memory table 4 .
Software Overview @CR1_SEND |= #RES_4_BIT ; set 8–Bit conversion mode .endif .if (EXTERNAL_CLOCK) @CR0_SEND ^= #CLK_INTERNAL ; clear CLK_INTERNAL bit if one @CR0_SEND |= #CLK_EXTERNAL ; set CLK_EXTERNAL mode .endif .if (DIFF_INPUT_MODE) @CR0_SEND ^= #SINGLE_END ; clear single ended input bit if one @CR0_SEND |= #DIFFERENTIAL ; set differential input mode .
Software Overview DP = #AD_DP ; ******************************************* * ADC_mono_con_Start: * read samples and store them into memory ******************************************* ADC_mono_con_Start: repeat(#12) NOP ; wait for t(SAMPLES) (450ns) STEP6: @ADSAMPLE = port(ADC) ; read the new sample into the DSP * IMPORTANT: fine–tune the counter number of the next repeat loop in order * to achive maximum throughput related to the delay of the store instructions STEP7: repeat(#7) NOP ; wait for t(
Software Overview .endif .if SAVE_INTO_MEMORY * test for table end, set pointer back if true TC = (AR0 ==AR7) ; is AR0 = AR7? (table end reached?) if (NTC) goto STORE_END ; * set pointer back to table start AR7 = #(data_loc_A) ; point to first date location of the storage table .
Software Overview Constants definition – see 8.6.1.1 Constants.asm Interrupt Routine handler – see 8.6.1.2 Interrupt Vectors 8.6.7 Dual Continuous Mode Mainprogram (DUALCON1.asm) ************************************************************************** * TITLE : TLV1562 ADC Interface routine * * FILE : DUALCON1.
Software Overview isr_save .usect ”.variabl”, 1 ; memory location to save AR7 during ; interrupts CH1_ADSAMPLE .usect ”.variabl”, 1 ; last readed sample of channel 1 CH2_ADSAMPLE .usect ”.variabl”, 1 ; last readed sample of channel 2 * Address Decoder constants: ADC .set 00002h ; activate A0 when TLV1562 is choosen RD_CALIBRATION .set 00001h ; activate A1 when CSTART is choosen DAC1 .set 00003h ; activate A2 when DAC1 is choosen DEACTIVE .
Software Overview repeat(#num_data_A–1) data(data_loc_A) = @TEMP ; fill memory table 1 repeat(#num_data_B–1) data(data_loc_B) = @TEMP ; fill memory table 2 repeat(#num_data_C–1) data(data_loc_C) = @TEMP ; fill memory table 3 repeat(#num_data_D–1) data(data_loc_D) = @TEMP ; fill memory table 4 .
Software Overview @CR1_SEND ^= #RES_10_BIT ; clear bit for 10–Bit Resolution @CR1_SEND |= #RES_4_BIT ; set 8–Bit conversion mode .endif .if (EXTERNAL_CLOCK) @CR0_SEND ^= #CLK_INTERNAL ; clear CLK_INTERNAL bit if one @CR0_SEND |= #CLK_EXTERNAL ; set CLK_EXTERNAL mode .endif .if (DIFF_INPUT_MODE) @CR0_SEND ^= #SINGLE_END ; clear single ended input bit if one @CR0_SEND |= #DIFFERENTIAL ; set differential input mode .
Software Overview @SWWSR = #07000h ; one I/O wait states DP ; = #AD_DP ******************************************* * ADC_dual_con_Start: * read samples and store them into memory ******************************************* ADC_dual_con_Start: repeat(#12) NOP ; wait for t(SAMPLES) (450ns) STEP6: @CH1_ADSAMPLE = port(ADC) ; read the new sample into the DSP STEP7: repeat(#20) NOP ; wait for t(CONV1) (about 800ns) STEP10: @CH2_ADSAMPLE = port(ADC); read the new sample into the DSP * IMPORTANT: fine
Software Overview @ADSAMPLE = A ; @ADSAMPLE |= #(TLC5618_LATCH_A|TLC5618_FAST_MODE|TLC5618_POWER_UP) ; set the mode of the DAC data(BDXR) = @ADSAMPLE ; send out the sample to the serial DAC SEND_SERIAL_END: .endif * test for table end, set pointer back if true .
Software Overview Constants definition – see 8.6.1.1 Constants.asm Interrupt Routine handler – see 8.6.1.2 Interrupt Vectors 8.6.8 C-Callable Mainprogram (C1562.c) /* File: C1562.
Software Overview ; .setsect ”.vectors”, 0x00180,0 ; sections of code ; .setsect ”.text”, 0x00200,0 ; these assembler directives specify ; .setsect ”.data”, 0x01800,1 ; the absolute addresses of different ; .setsect ”.variabl”, 0x01800,1 ; sections of code .sect ”.vectors” .copy ”vectors.asm” .sect ”.data” .copy ”constant.asm” AD_DP .usect ”.variabl”, 0 ; ACT_CHANNEL .usect ”.variabl”, 1 ; jump address to init. new channel ADWORD .usect ”.
Software Overview * initialize storage table for the ADC samples DP A = #AD_DP ; += #–1 ; decrement A @CH_NO = A ; read number of sampling channel A = @ADMEM AR7 = A ; point to first date location of the storage table A = @ADCOUNT ; AR0 points to table end B = @ADMEM A += B AR0 = A ; AR0 is loaded with last save location AR5 = #(IFR) ; AR5 points to the IFR register (only for polling mode) DP = #AD_DP @ZERO = #00000 ; set the dummy send value * initialize the send values to set
Software Overview ADC_mono_IRQ_Start: ISTEP2: XF = 0 ; clear CSTART ISTEP3: NOP NOP NOP ; wait for TW(CSTARTL) ISTEP4: XF = 1 ; set CSTART STEP5: * wait until INT– goes low in polling the INT0 pin: M1: TC = bit(*AR5,15–0) ; test, is the INT0 Bit in IFR=1? if (NTC) goto M1 IFR ; wait until INT– signal went high = #1 ; reset any old interrupt on pin INT0 * read sample STEP2: XF = 0 ; clear CSTART STEP10: @ADSAMPLE = port(ADC) ; read the new sample into the DSP STEP4: XF ; wait for TW(CST
Software Overview BXINT0: return_enable ; interrupt is not in use .end Vectors.asm ************************************************************************** * TITLE : TLV1562 ADC Interface routine * * FILE : VECTORS.ASM * * FUNCTION : N/A * * PROTOTYPE : N/A * * CALLS : N/A * * PRECONDITION : N/A * * POSTCONDITION : N/A * * SPECIAL COND.
Software Overview nop nop nop int2 return_enable ;48; external interrupt int2 nop nop nop tint return_enable ;4C; internal timer interrupt nop nop nop brint return_enable ;50; BSP receive interrupt nop nop nop bxint goto BXINT0 ;54; BSP transmit interrupt nop nop trint goto trint ;58; TDM receive interrupt return_enable ;5C; TDM transmit interrupt nop nop txint nop nop nop int3 return_enable ;60; external interrupt int3 nop nop nop hpiint goto hpiint ;64; HPIint * DO NOT MODIFY IF USIN
Software Overview Constants definition – see 8.6.1.1 Constants.asm and for Interrupt Routine handler – see 8.6.1.2 Interrupt Vectors Auto.bat @ECHO ON del *.map del *.obj del *.out del *.lst del *.cnv cl500.exe –k –n c1562.c pause mnem2alg.exe c1562.asm pause asm500 asm1562.asm –l –mg –q –s pause asm500 c1562.cnv –l –mg –q –s pause lnk500 linker.cmd Linker.cmd /******************************************************************/ /* File: Linker.lnk COMMAND FILE */ /* */ .
Summary .text : {} > PROG PAGE = 0 .vectors : {} > VECT PAGE = 0 .data {} > RAMB0 PAGE = 1 : .variabl : {} > RAMB0 PAGE = 1 .stack {} > STAC PAGE = 1 : } 9 Summary This application report provides several software application examples and recommendations for simplifying the software, through modifications to the DSP hardware interface circuit. The user can customize any of the number of software routines provided in this document to fit his specific applicaltion.