⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ee_call.txt

📁 Microchi PIC Hi-Tech_C I2C_for_24LC01_and_Dalla_temperature
💻 TXT
字号:
***** I2C Routines for PIC micro in Hi-Tech C to write to Microchip 24LC01 
non-volatile memory, and Dallas Temperature sensors DS1775 and DS1721

Many thanks to Cameron Pearce [cpearce@sunesi.com] for the C and 
email.  He has been programming for 5 years and has excellent coding skills.

Note: to use this code with a Microchip 24LC256, you need a 16-bit address as 
the 24LC256 has 256Kbit of memory.

*****
To write a byte to the eeprom at a certain address, you do the following:

Write a byte 0x55 to address 0xAA.
	
if(ee_byte_to_ee(0xAA, 0x55))
	
SUCCESSFULL!!
	
else
	
UNSUCCESSFULL!!

Remember that when you write a byte, it takes 5-10mS for an internal write.
This timing is not part of my code.  Unfortunately some of the code is not
well commented, but I will answer any questions you may have.

*****
To read a byte at an address, do the following:	

Read from address 0x20.

unsigned char cByteToRead;
	
if(ee_byte_from_ee(0x20, &cByteToRead))
	
SUCCESSFULL!!
								 else
	
UNSUCCESSFULL!!

*****
I have also written some code to access the Temperature sensors from Dallas.
The two chips are DS1775 and DS1721.

To configure the DS1775 (accuracy, ect.), do the following:
if(ConfigByteDS1775(MyConfigByte))
	
SUCCESSFULL!!
	
else
	
UNSUCCESSFULL!!

To read the temperature from a DS1775, do the following:	unsigned
char cMSByte, LSByte;

	
if(ReadTemperatureFromDS1775(&cMSByte, &cLSByte))
	
SUCCESSFULL!!
	
else
	
UNSUCCESSFULL!!
The temperature sensor returns a two byte result.  These two bytes has to be
joint to get the result in degrees C.

The DS1775 also has a internal pointer, which is used to point to the
location you wish to read/write.  This pointer can be set using the
following code:
if(SetDataPointerDS1775(SetPointer))
	
SUCCESSFULL!!
	
else
	
UNSUCCESSFULL!!

The code for the DS1721 is more or less the same.  One difference I found
with the DS1721 is that it requires a repeated start I2C condition,
something I haven't found with other chips before.  I wrote this
ee_RepeatStart(); for repeated starts.

Cheers
Cameron

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -