_______________________________________________________________________ > < > DS1624 (TEMP sensor) driver < > for < > PICos18 release 2.03 < > < > PICos18 - Real-time kernel for PIC18 family < > < > < > www.picos18.com www.pragmatec.net < >_______________________________________________________________________< This file contains all necessary informations to use properly the DS1624 temperature sensor driver for PICos18 v2.xx. This driver lets you design a multi-task application using the MAXIM DS1624 that can manage a 13-bit temperature resolution. This temperature sensor has to be access through the I2C interface and this driver lets you have a safe access to this chip without woring about multiple I2C bus access. _______________________________________________________________________ > < > I - Zip file content < >_______________________________________________________________________< The drv_DS1624 zip file contains : - drv_DS1624.c - drv_DS1624.h : header file - drv_DS1624.txt : this file To use the temperature sensor driver, first unzip the file. Place the C and H files in your project directory. This driver is supposed to be use with PICos18 and has been tested with MPLAB 7.10 and C18 v2.42. This driver is suitable for PIC18 with MAXIM/ DALLAS DS1624 device. _______________________________________________________________________ > < > II - Hardware settings < >_______________________________________________________________________< Have a look at the DS1624 datasheet to connect your device properly to the I2C bus. If you already have a I2C install you don't have to plug additional pullup resistors. A basic installation consists to connect the chip to the power lines (VDD and VSS) and defining the I2C address of the current device wiring the A0, A1 and A2 pin to a logic level, then to connect the SDA and SCL lines to the PIC18 (with pullup resistors if needed). _______________________________________________________________________ > < > III - TASCDESC settings < >_______________________________________________________________________< The DS1624 driver needs the I2C driver to be install at first. Have a look at the drv_I2C.txt file to learn more on how to install such a driver. The DS1624 driver is not exactly a driver but much more a library (a set of functions) that let you interface the DS1624 without wasting time to validate your own code during many hours. Then once you have properly install the I2C driver you don't need to specify anything else in the tascdesc.c file. _______________________________________________________________________ > < > IV - DS1624 basic usage < >_______________________________________________________________________< First of all you need to declare two I2C_message structures in your task. It's mandatory for all the tasks that need to use the I2C driver : I2C_message_t I2Cconvert_msg; I2C_message_t I2Ctemp_msg; In the TASK0 task of the MyApp directory, include the driver header: #include "drv_DS1624.h" Define the DS1624_address field for both DS1624Convert_t and DS1624Temp_t structures with the I2C address of the current target device. In this example : DS1624_ADDRESS_1 is one of the eight available addresses and is defined as 0x90. See hereafter a basic example to have a correct access to the DS1624: the task first initiate the device starting continuous temperature conversions and then access the DS1624 each 1s to acquire the result. #include "define.h" #include "drv_DS1624.h" /********************************************************************** * Definition dedicated to the local functions. **********************************************************************/ #define ALARM_DS1624 0 I2C_message_t I2Cconvert_msg; I2C_message_t I2Ctemp_msg; DS1624Convert_t I2Cconvert; DS1624Temp_t I2Ctemp; /********************************************************************** * ----------------------------- TASK0 -------------------------------- * * First task of the tutorial. * **********************************************************************/ TASK(TASK0) { I2Cconvert.DS1624_address = DS1624_ADDRESS_1; I2Cconvert.convert_temp = START_CONVERT; I2Ctemp.DS1624_address = DS1624_ADDRESS_1; SetRelAlarm(ALARM_DS1624, 1000, 1000); WaitEvent(ALARM_EVENT); ClearEvent(ALARM_EVENT); DS1624_Convert(&I2Cconvert_msg, &I2Cconvert); while (1) { WaitEvent(ALARM_EVENT); ClearEvent(ALARM_EVENT); DS1624_Temp(&I2Ctemp_msg, &I2Ctemp); } } _______________________________________________________________________ > < > V - Conclusion < >_______________________________________________________________________< The DS1624 device is shipped with the Configuration Register set for continuous temperature conversions, thus all you need to initiate the DS1624 to perform temperature conversions is issuing the START_CONVERT command using the DS1624_Convert( ) function provided in this driver. With the same function you might also halting the continuous temperature conversions issuing the STOP_CONVERT command. The other 3 functions of this DS1624 driver offer an easy access to the acquired temperature and to the internal EEPROM. The DS1624 sensor mesures temperatures from -55°C to +125°C in 0.03125°C increments. Temperature is read as a 13-bit value in a 2 bytes transfer. The on board EEPROM memory is of 256 bytes. /* End of File : drv_DS1624.txt */