Microcontroller Based Data Acquisition Using the TLC2543 12-Bit Serial-Out ADC SLAA012 July 1995 Printed on Recycled Paper 0
IMPORTANT NOTICE Texas Instruments (TI) reserves the right to make changes to its products or to discontinue any semiconductor product or service without notice, and advises its customers to obtain the latest version of relevant information to verify, before placing orders, that the information being relied on is current. TI warrants performance of its semiconductor products and related software to the specifications applicable at the time of sale in accordance with TI’s standard warranty.
Contents Title Page Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Scope of this Application Report . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . The TLC2543 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
List of Illustrations Figure Title Page 1. TLC2543 Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2. Timing for 16-Clock Transfer Using CS With MSB First . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 3. Timing for 16-Clock Transfer Not Using CS With MSB First . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 4. Serial Peripheral Interface – Internal Structure and Data Flow . .
Introduction Scope of this Application Report This application report describes how to construct 12-bit data acquisition systems using the TLC2543 serial-out analog-to-digital converter (ADC) in conjunction with a range of four popular microcontrollers. The four microcontrollers used are the TMS370, H8/300, 68HC11 and 80C51.
Figure 2 shows the timing for the method which uses 16 clock cycles for each conversion and data transfer cycle and which inserts CS between each of these transfer cycles. Figure 3 shows the timing for the method which uses 16 clock cycles for each conversion and data transfer cycle but inserts CS only once at the start of each sequence of conversions. This application report describes various microcontroller interfaces, each of which uses 16 clock cycles for each conversion data transfer.
Serial Peripheral Interface (SPI) The fastest and most efficient method of implementing a data transfer between the TLC2543 and a microcontroller is to use the serial peripheral interface (SPI) of the microcontroller, if this is available. The TMS370 (Texas Instruments), H8/300 (Hitachi) and MC68HC11 (Motorola) all offer SPIs (or the equivalent ) in a subset of each of these families of microcontrollers.
CS I/O CLOCK DATA IN DATA OUT B7 A15 B6 B5 B4 B3 B2 A14 A13 A12 A11 A10 B1 A9 B0 A8 B7 A7 B6 A6 B5 A5 B4 B3 B2 B1 B0 A4 A3 A2 A1 A0 ( = 0) ( = 0) ( = 0) ( = 0) tconv EOC Figure 5. TLC2543 to SPI Interface Timing Software Flowcharts Figures 6, 7, and 8 show the flow charts for the main program and subroutines used in the TLC2543 to TMS370C010 interface software shown in this application report.
Read Channel/Mode Data Into Chosen Register Store MSBYTE In Even Address Of RAM (Channel # Dependant) Map Channel Numbers To Registers Or RAM Store LSBYTE In Odd Address Of RAM (Channel # Dependant) Put Destination Address Into Chosen Register STORE Return DATAIN Figure 7.
TLC2543 TO TMS370 Microcontroller Interface Microcontroller Features Within the family of TMS370 microcontrollers there are several versions which contain a serial peripheral interface (SPI) facility. One of these versions should be chosen to implement the interface method described below. One such version is the TMS370C010 which is used to illustrate the method. Interface Circuit Figure 9 shows the circuit interconnections for the TLC2543 to TMS370C010 microcontroller interface.
The user can put channel select and ADC mode control data into the holding register within the microcontroller, via the 8-bit wide port A bidirectional I/O port, using a bank of eight toggle switches as shown in Figure 9. Alternatively, the mode and channel data can be sent to the microcontroller holding register via the asynchronous serial communications interface (SCI). This option is available only on those versions of the TMS370, such as the TMS370C020, which include both SPI and SCI interfaces.
List 1 (Continued) LINE 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 8 LOC 402b OBJ ’00d3 402d 402f 9122 d10b 4031 4033 4034 4035 4036 4037 4039 403b 53f0 cc cc cc cc 5c02 5840 d10a 403d f9 403e 4040 4043 4044 4046 4047 4049 404b 404d 4051 4053 2203 a4802e b2 ’06fd c5 512e 2207 2131 ’76020b19 120b 2139 4055 405
List 1 (Continued) LINE 129 130 131 132 133 134 135 136 137 138 139 LOC OBJ 409c f9 409d 409f 40a1 40a3 40a5 40a7 1214 9b0a d30a 1215 9b0a f9 SOURCE RETURN RTS ; ;Subroutine :– STORE ; STORE MOV R20,A MOV A,@R10 INC R10 MOV R21,A MOV A,@R10 RTS .
VCC1 VCC2 VCC VCC VP0610 470 R SPICLK I/O CLOCK 1/2 GCPL2631 470 R TLC2543 TMS370 VP0610 470 R DATA INPUT 1/2 GCPL2631 470 R VP0610 470 R DATA OUT AIN0 AIN1 AIN2 AIN3 AIN4 AIN5 AIN6 AIN7 AIN8 AIN9 AIN10 SPISOMI D7 470 R VP0610 CS A0 A1 A2 A3 ADC Mode A4 A5 A6 A7 ADC Channel Number HCPL2601 470 R VSS VSS 3 kV Isolation Barrier Figure 10.
TLC2543 to H8/325 Microcontroller Interface Microcontroller Features The individual members of the H8 family of microcontrollers can be differentiated by various criteria, for example the inclusion or otherwise of an on-board 8-bit resolution analog-to-digital converter (ADC). Those members which include an ADC generally cost between 10 and 20 percent more than their counterparts which do not.
List 2 LINE 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 12 LOC OBJ SOURCE ;* * * * * * * * * * * * * * * * * * * * * ;* * ;* TLC2543 to H8 Microcontroller Interface Program. * ;* * ;* This program contains subroutines DATAIN, ADC, * ;* FORMAT and STORE. * ;* DATAIN reads channel number and mode data into the * ;* microcontroller via Port4.
List 2 (Continued) LINE 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 LOC OBJ SOURCE 1052 47FA 1054 23DD BEQ TESTB61 MOV.B @RDR:8, R3H 1056 7FDC7260 105A 68D3 BCLR #6, @SSR:8 MOV.
List 2 (Continued) LINE 136 137 138 139 140 141 14 10C4 10C6 10C8 10CA 10CC 10CE LOC 120F 1A00 46F8 0CFB 5470 OBJ SOURCE ROTXL R7L DEC R0H BNE LOOP2 MOV.
TLC2543 to MC68HC11 Microcontroller Interface Microcontroller Features All members of the MC68HC11 family of microcontrollers contain an SPI. As is the case for the TMS370, the user is able to set the idle level of the serial clock of the 68HC11. This eliminates the need for an external inverter to be used to invert the microcontroller’s serial clock output prior to its arrival at the TLC2543’s serial clock input. The 68HC11D0, 68HC11D3 and 68HC711D3 versions do not contain an on-board ADC.
List 3 LINE 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 16 A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A LOC OBJ SOURCE * * * * * * * * * * * * * * * * * * * * * * TLC2543 12–bit Serial Out ADC to MC68HC11 Microcontroller * Interface Program * * This program co
List 3 (Continued) LINE 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 95 96 97 A A A A A A A A A A A A A A A A A A A A A A A A A A A A A A LOC OBJ F849 39 F84A F84C F84F F851 F853 F855 F856 F857 F858 F859 F85A F85C F85D F85F F861 F863 F864 F866 F866 F868 A603 CE0030 97F2 86F0 94F2 46 46 46 46 16 8602 3D DDF2 96F0 A7F2 08 96F1 A7F2 A7F2 39 SOURCE * If MSB/LSB–first bit = 1 go to MSB RETURN RTS * * S’routine stores MSByte in even address * LSByte in odd address * Chan
TLC2543 to 80C51 Microcontroller Interface Microcontroller Features The 80C51 microcontroller family does not provide an SPI or equivalent facility. In order to implement the interface with the TLC2543 analog-to-digital converter, it is necessry to use software to synthesize the operation of an SPI. This results in a slower data transfer rate which is governed by the microcontroller’s instruction cycle times. These are, in turn, influenced by the clock frequency of the microcontroller.
The second byte of data is tranferred between the TLC2543 and the 80C51 by repeating the entire sequence of eight sets of data transfer and clock pulse. The MSByte is placed in register 2 (R2) and the LSByte is placed in register 3 (R3). The subroutine STORE is used to map the MSByte and LSByte conversion results into even and odd number RAM addresses corresponding to the particular channel number which has been selected.
List 4 (Continued) LINE 0146 0147 0149 014A 014B A4 2430 F9 EA F7 014C 09 014D EB 014E F7 014F 22 20 LOC OBJ SOURCE 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 MUL ADD MOV MOV MOV AB A,#030H R1,A A,R2 @R1,A INC R1 MOV A,R3 MOV @R1,A RET END ;Add 30H to accumulator ;Put MSByte in corresponding ;even number address :– ;Channel 0 in address 30H, ;Channel 1 in address 32H etc. ;Put LSByte in corresponding ;odd number address :– ;Channel 0 in address 31H, ;Channel 1 in address 33H etc.
Analog Considerations Power Supply Decoupling Care should be taken with the design of the printed circuit board when using 12-bit devices such as the TLC2543. The power supply terminal of each analog integrated circuit should be separately decoupled to the analog ground using a 0.1 µF ceramic capacitor. The inclusion of a 10 µF tantalum capacitor in parallel with the ceramic capacitor at each device supply terminal is also recommended, particularly in noisy environments.
Appendix A References H8/325 Hardware User’s Manual H8/300 Series Programming Manual Embedded Microcontrollers and Processors Vol 1 M68HC11 Reference Manual (1991) TMS370 Family Data Manual (1993) TLC2543 Data Sheet (Dec. ’93) Hitachi Hitachi Intel Corporation Motorola Inc.