In recent years, IC manufacturers have designed various methods to realize the interface, and pay special attention to reducing the number of I / O pins of IC interface. Max187 is such a device. It is a 12 bit analog-to-digital converter (ADC). You can use serial data communication technology to generate an interface with the ADC. Max187 only needs three digital I / O lines for analog-to-digital conversion and data transmission. You can use the PC’s Centronics printer port to create a simple interface between the max187 and the PC (Figure 1). You can enable or disable max187 (pin 3) by setting the pin to high or low respectively. If this pin is opened, the internal reference voltage (4.096V) is disabled. You must add an external reference voltage to pin ref (pin 4). In other cases, this pin is associated with 4.7 μ F bypass capacitor C1 connection. By using the external clock pulse on SCLK pin (pin 8), the digital data from max187 is transmitted to the processing unit at the speed of 1 bit at a time.
A complete data transmission requires 13 external clock pulses. The falling edge of the first clock pulse latches the first data bit (MSB) of the dout pin (pin 6). The output data bit changes at the falling edge of the next external clock pulse, and the serial data bit can be read until the falling edge of the next clock cycle appears. The A / D conversion starts when the ADC pin (pin 7) becomes low. This pin must
The low level must be maintained until the end of the entire A / D conversion cycle, followed by serial data transmission. The state change of dout pin from low level to high level indicates the EOC (end of conversion) state. Then, the serial 12 bit data can be transmitted. The operation of max187 is controlled by software. The software shall be able to generate all control signals required for successful conversion and detect EOC status. It shall also be able to generate 13 external clock pulses to read serial 12 bit data and convert it into parallel data.
The software that controls the operation of max187 is Turbo C + + version 3.0 (which can be downloaded from the web version of design example on the website). In the code, port defines the Centronics port of the PC that interfaces with max187. Write port defines the port used to initialize a / D conversion and generate external clock pulses. Read port defines the port used to read EOC and serial data from the ADC. After the CS pin and SCLK pin are pulled down to the low level, the EOC loop checks the EOC status. If no valid EOC occurs, the loop will continue to operate. When a valid EOC occurs, the first of the 13 clock cycles occurs and the first data bit (MSB) is latched. After that, the routine calls a subroutine (get)_ adc（））。 The subroutine generates the remaining external clock cycles to read 12 bit serial data. The subroutine also converts the received serial data into parallel data (ADC_ val）。 This conversion process is: make ADC_ Val shifts one bit to the left, thereby multiplying the previous data by 2. If the value of the serial data bit is 1, 1 is added to the parallel data. Once the parallel data is ready, the subroutine returns this value and displays it on the screen.
Figure 1 it is easy to realize the interface between 12 bit serial ADC and PC.