資源簡介
用于DSP 6713的i2c訪問代碼
對(duì)于初學(xué)者是非常實(shí)用的例子哦

代碼片段和文件信息
/*********************************************************************************
*?DEC6713_EEPROM.C ver1.0 ????? ????????????????????????????*
*?Copyright 2008?by?Hunan?Geoson?Hi-Tech?Ltd.
*?All?rights?reserved.?Property?of?Hunan?Geosun?Hi-Tech?Ltd. ????????????????*
*?Write?by: Zhili.Zeng
*?Email: zzl290@163.com ????????????????????????????????*
*********************************************************************************/?
/*********************************************************************************
Program?for?test?I2C?module.
Bit?Polling?Mode.
Writting?and?reading?operation?on?I2C?device.?
*********************************************************************************/
#define?I2C_SLAVE_ADDRESS?0x50 //Set?slave?address?of?i2c?device
//#define?I2C_DataLen?4 //The?number?of?bytes?you?access?a?time
#include?“i2c.h“
#include? //Used?only?for?debug?
unsigned?short?I2C_Add=0x0020; //The?memory?address??to?be?accessed
unsigned?char?I2C_DataLen? =?4; //The?number?of?bytes?you?access?a?time
unsigned?char?I2C_DataSend[4]? =?{0x000xaa0x550xff};//The?data?to?be?write?
unsigned?char?I2C_DataRec[4]? =?{0000}; //The?data?you?read
unsigned?char?I2C_ByteSend =0x55; //The?byte?to?be?write
unsigned?char?I2C_ByteRec =0; //The?byte?you?read
/*********************************************************************************
*******************************?This?is?a?example.?*******************************
***You?may?modify?the?value?of?I2CPSC\I2CCLKH\I2CCLKL?in?I2C_Init()?before?use.***
****These?registers?are?used?to?set?data?transfer?ratefrom?10kbps?to?400kbps.****
*********************************************************************************/
main()
{
unsigned?int?j;
????
I2C_Init();
//Write?or?read?more?than?one?byte?a?time.
I2C_WriteData(0I2C_DataSendI2C_DataLen);
printf(“\nWrite?data?is?over.“);
printf(“\nThe?Data?you?write?is?%x%x%x%x“I2C_DataSend[0]I2C_DataSend[1]I2C_DataSend[2]I2C_DataSend[3]);
I2C_ReadData(0I2C_DataRecI2C_DataLen);
printf(“\nReading?data?is?over.“);
printf(“\nThe?Data?you?read?is?%x%x%x%x“I2C_DataRec[0]I2C_DataRec[1]I2C_DataRec[2]I2C_DataRec[3]);
//Write?or?read?one?byte?a?time.
I2C_WriteByte(0x0200&I2C_ByteSend);
printf(“\nReading?data?is?over.“);
printf(“\nThe?byte?you?write?is?%x“I2C_ByteSend);
I2C_ReadByte(0x0200&I2C_ByteRec);
printf(“\nReading?data?is?over.“);
printf(“\nThe?byte?you?read?is?%x“I2C_ByteRec);
for(j=0;j<200000;j++);
// while(1);
}
/*********************************************************************************
????End?of??DEC6713_EEPROM.C
*********************************************************************************/
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件????????453??2008-07-23?10:25??i2c\cc_build_Debug.log
?????文件??????12784??2008-07-23?10:25??i2c\Debug\i2c.map
?????文件???????8638??2008-07-23?10:25??i2c\Debug\i2c.obj
?????文件??????55749??2008-07-23?10:25??i2c\Debug\i2c.out
?????文件???????2740??2008-07-23?10:25??i2c\Debug\vecs.obj
?????文件????????298??2008-07-23?10:25??i2c\Debug.lkf
?????文件????????298??2008-07-23?10:25??i2c\Debug.lkv
?????文件??????13284??2004-12-01?16:05??i2c\DEC6713.gel
?????文件???????2780??2008-07-23?10:25??i2c\i2c.c
?????文件???????1078??2004-11-22?11:03??i2c\i2c.cmd
?????文件???????8143??2008-07-23?10:22??i2c\i2c.h
?????文件???????1535??2008-07-23?10:25??i2c\i2c.paf
?????文件????????889??2008-07-23?10:23??i2c\i2c.pjt
?????文件???????3628??2004-11-22?11:03??i2c\vecs.asm
?????目錄??????????0??2009-02-13?23:24??i2c\Debug
?????目錄??????????0??2008-07-22?08:43??i2c\include
?????目錄??????????0??2009-02-13?23:24??i2c
-----------?---------??----------?-----??----
???????????????112297????????????????????17
- 上一篇:ginger premium
- 下一篇:基于labview的AD轉(zhuǎn)換
評(píng)論
共有 條評(píng)論