9 » IC Electronic information » Category: D

IC Electronic information

DS1621 in the IIC interface driver under Linux Design

In Electronic Infomation Category: D | on April 22,2011

Abstract: Aiming at the IIC bus and CA5160E datasheet and the IIC interface chip with embedded systems in a wide range of applications, designed based on the S3C2440 ARM9 platform, Linux operating system under the IIC interface device driver. Through the IIC bus protocol, the driver realized the state in the kernel of the configuration of DS1621 digital temperature sensor and CA5160E price and access to the temperature information, and CA5160E suppliers and returns the user space and print display. The results show that the typical working data update time 1 s, an accuracy of one decimal place. And the use of a multi-chip DS1621 scalable low-voltage, low power multi-point digital temperature measuring system, temperature monitoring of embedded devices will have a wide range of applications.

IIC bus, the bus as a transmission line applications, the use of connections, simple structure, is a widely used method of high-performance bus. The Linux source code as an open, easy to cut the operating system, is ideal for embedded systems applications. Embedded Linux operating system, device drivers, through the IIC bus, ARM and peripheral modules to achieve interoperability, with a wide range of applications.

1 IIC bus protocol and the selection of chip features

1.1 IIC bus characteristics and work agreements

IIC serial bus signal lines by the two components: a two-way transmission of data line SDA; the other root is the clock line SCL. IIC bus is a simple structure that is able to achieve half-duplex synchronous data transmission.

IIC bus using a master and more from the operating mechanism, at the same time there can be only one device as the primary equipment, the operation of the bus by the master control, master control data transmission start signal, the clock signal sent from the machine address signals, data signals transmitted by the receiving end of the data side in an acknowledge signal, each IIC bus device has a unique address, and the main equipment to communicate.

IIC bus timing shown in Figure 1, the IIC bus use, transmission start and stop conditions are as follows: When the SCL continues to "1" and SDA from "1" to "0" that will begin sending data; and when SCL continues to "1" and SDA from "0" to "1" means to stop sending data. SDA data line where the clock line SCL to "1" must be stable during the period, and only when the SCL line low, the data clock signal to change the state line.

Figure 1 IIC bus timing diagram

SDA line must be 8 bits per byte, each transfer does not limit the number of bytes, each byte sent a reply has an ACK bit.

1.2 Features selection of ARM9 chips

MCU chip with a companys S3C2440, S3C2440A is a company based on a 16/32-bit ARM920T RISC core embedded microprocessor, mainly for handheld devices, and cost-effective, low-power applications, and integrated an IIC bus controller, and can easily communicate with IIC interface to peripherals.

1.3 chip digital temperature sensor DS1621 Features

DS1621 DALLAS produced is a powerful digital temperature sensor and temperature controller. IIC bus compatible interface, a controller can control up to eight of the DS1621, working voltage is 2.7 ~ 5.5 V, for low-power applications.

DS1621 can be used alone as a thermostat, 2-wire interface can also be under the control of the ARM-temperature measurements and calculations. Register settings can be adjusted. DS1621 can measure temperature without external components, the results amount to 9 digits (two bytes) is given, measuring range -55 ~ +155 , an accuracy of 0.5 : Typical conversion time of 1 s.

2 Circuit Design S3C2440 as

designed with the main circuit, control IIC bus slave device, controlled by the master clock signal on the IIC bus, and a variety of data signals. As with two DS16 21 IIC bus slave device, the DS1621 with IIC bus interface directly with the SDA and SCL pins S3C2440 phase, through the DS1621s A2, A1, A0 pin (Pin 5,6,7) enter a different combination of chip-select signal, can be determined to work in the IIC bus slave address. Because the IIC devices are generally from the MOS process, so the bus has a pull-up resistor. Work, through the IIC bus, the DS1621 temperature sensor is set to successive data acquisition functions and working methods, the circuit schematic design shown in Figure 2.

circuit diagram in Figure 2

3 Driver

Driver in Linux, all the devices as files, drivers, applications and hardware devices was provided between the operating access interface, so that applications can operate as ordinary file access operations on the hardware device. Linux kernel the driver is divided into 3 types: character devices, block devices and network equipment. Among them, the character devices and block devices can be accessed the same as the file. DS1621 The IIC is a character device driver.

Started work, DS1621s work is set by the chip / status register to determine: 1) When writing through the IIC bus read and write to the DS1621 after ACh ARM Set command issued a byte will set the DS1621s work way, and then issue the temperature conversion command EEh, read temperature command AAh; 2) DONE bits that work in the temperature measurement function, the temperature data has been converted completed, stored in nonvolatile register; 3) THF, TLF is the DS1621 as thermostat when the state identifies the bit, when more than TH or lower than the preset value of the preset value of TL is set to 1; 4) 1SHOT as a mode bit, the bit is 1, each received the command to perform a temperature conversion temperature conversion, the temperature of 0 performs a continuous conversion. DS1621 configuration register is shown in Figure 3.

Figure 3 DS1621 register configuration

Found in the debugging process, the use of continuous conversion mode, occurs in very rare cases the data was incorrect, so the use of a sequential read mode, the successive configurations DS1621 temperature conversion, successive access to data, and each times to determine DS1621 working condition, the data range and precision to gain a more stable and accurate results.

Drivers include: initialization and releasing hardware; S3C2440 through the IIC bus control register of the DS1621 configuration; S3C2440 register reads the DS1621 temperature data through the interface functions to send data from kernel space to user space. Driver Design flow chart shown in Figure 4.

driver design flow chart in Figure 4

3.1 The main function device driver

For character devices, Linux kernel for these operations a unified abstraction, they are defined in the file-operation in the structure. Typically, the character devices to the application of a flow control interface, including open, release, read, ioctl, etc..

3.2 from the device, the device DS1621 initialization code

3.3 IIC bus initialization

The IIC controller on S3C2440 need to use configuration registers are: IICCON, IICSTAT, IICDS, IICADD.

IICCON: IIC bus control register; IICSTAT: IIC bus control status registers; HCDS: IIC bus receive / transmit data shift register; IICADD: IIC Bus Address Register.

1) S3C2440s GPE15 as HCSDA, is a serial data cable port, GPE14 as IICSCL, is a serial clock line;

2) the IICCON set to: 0xA7, said the transfer process to enable ACK response, IIC clock work: HCCLK = fpclk/512, IlC bus interrupt is enabled, data transmission clock: Tx clock = IICCLK / (IICCON [3: O] +1), about 400 k / s;

3) will IICSTAT set to: 0x10, that is used to receive data from the device mode, the data output / receive enabled.

3.4 bus master read data from the HC

For the DS1621 configuration register, when read through the IIC data from the DS1621 device, the need to switch the direction of data transceiver, S3C2440 first mode, the host sends data to send from the address from the device DS1621, DS1621 internal sub-registers address and write signal bit, and then receive data mode, the host, once again sent to the slave address and read signals from the bit, and data within the sub-address read back, the read data operation shown in Figure 5.

Figure 5 IIC bus read data manipulation

Where to send the beginning symbol S START, W for the write signal bit, R bit to read the signal, A signal for the ACK response, RS for repeated start signal REPEATED START, NA for the host to recover data sent NACK signal, P is stop signal STOP.

3.5 master IIC bus to write data

3.6 S3C2440 temperature data obtained from the DS1621, save and send in the kernel space to user space

4-driven load and test

Applications will drive the data obtained from the kernel space preservation, the first based on the returned DONE bit temperature sensor to determine whether it is data conversion process, if so, discard the data, and print data is not available information ; If not, then the next bit based on the accuracy of the data to determine the value after the decimal point, and the results printed out.

Finally, compile the driver module, you can dynamically load, unload device drivers, do not restart the system the driver can see the results, to facilitate the drive to write and debug work.

By dynamic compilation, get the target file iic.o, 1621.o and application 1621_iic_test, to download the file to the S3C2440, through # insmodiic.o, # insmod 1621.o load the module, # ./1621_iic_test run test program, shown in Figure 6.

Figure 6 Run the test program and print information

5 Conclusion

ARM920T kernel S3C2440 this paper for the MCU and the DS1621 digital temperature sensor module built into a multi-point digital temperature measurement circuit. MCU through the IIC bus to communicate with the DS1621, by writing under the IIC linux2.4 version of the driver to complete the S3C2440 and peripheral chips with IIC interface communication, and to achieve the DS1621 configuration and temperature work, work in the DS1621 The typical temperature conversion time is 1 s, the data accuracy of 0.5 , the typical voltage and current values ??of only 3 V, 10A, with high accuracy, low power consumption and their own work. By increasing the number of pieces to use DS1621 can also be extended to a low voltage, low power multi-point digital temperature measurement system can be widely used in embedded systems. Drivers can be used for other peripheral chips interface with IlC work can also be applied to other drive interfaces with the peripheral device communication IIC.

CA5160E datasheetCA5160E suppliersCA5160E Price

All right © 2010-2016 Certificate