8.3.9Enabling Software Modules (.if/.elseif/.endif)

Software Overview

8.3.9Enabling 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 .set 00001h

SWITCH2 .set 00000h

...

.if SWITCH1

instruction_X ; the instructions on this line will be assembled

.elseif SWITCH2

instruction_Y ; the instructions on this line will be ignored

.endif

In this example, instruction_X is executed (linked into object code) while instruction_Y is ignored. Setting SWITCH2 instead of SWITCH1 to 1 enables instruction_Y and makes the compiler link it to object code. If both switches are one, only instruction_X is compiled.

8.4Software Code Explanation

The next capture describes the software solution to interface the TLV1562 and the two DACs on the EVM board. Although the code looks very large and complicated at first, it is a simple solution with only a little knowledge of the code required to verify/customize the settings. The TLV1562 (ADC) offers a wide choice of settings. First, choose the conversation mode. This application report provides one file for each mode. Many settings (2s complement, channels, etc.) must be selected. This software allows a variation of those parameters in the program header. A simple switch enables or disables each component. After recompiling the code with a special setting of all switches, the code becomes much smaller and easier to understand. The .if/.elsif/.endif instruction allows the program to use or ignore blocks of instruction between the statements.

If, for example, one does not want to use the serial DAC and disables the switch SEND_OUT_SERIAL, all the source code for the serial conversation between DSP and DAC is ignored. The compiler will not implement any code related to the serial DAC.

8.4.1Software Principals of the Interface

Controlling the status of signals can be done in different ways. One of the challenges in this interface is controlling signal status when the ADC conversion is finished and the digital result is ready to be transferred from the ADC to DSP. A high/low transition on the INT line of the TLV1562 informs the DSP that the ADC has completed the conversion. Optionally, the DSP can ignore the INT signal, initialize the conversion instead, wait for a defined time, and directly read the result out of the ADC. This solution requires knowing the precise time for conversion/data ready on the bus for each converter/mode.

Three options are given for each mode to match different custom needs; they are listed in the next three sections.

Interfacing the TLV1562 Parallel ADC to the TMS320C54x DSP

23

Page 29
Image 29
Texas Instruments TLV1562 manual Enabling Software Modules .if/.elseif/.endif, Software Code Explanation