您的位置:首页 > 服装鞋帽 > 女装 > HCS12XEP100 查询方式IIC 发送

HCS12XEP100 查询方式IIC 发送

luyued 发布于 2011-06-30 23:50   浏览 N 次  

//Name:IIC of HCS12XEP100

//Description:查询方式IIC通讯,为了让通讯过程更清晰,没有写成函数,而是按时序写的执行语句

//参考了Freescale的官方应用笔记

//Date:05/08/2011
//Written by RXDu, NCEPU

#include
#include "derivative.h"

void InitIIC(void)
{
//IIC0_IBFD=0x96; //SCL Devider 416 Rate=80M/416
IIC0_IBFD=0x14;
IIC0_IBAD=0xf0;
IIC0_IBCR=0x80;
IIC0_IBCR2=0x80;
IIC0_IBSR_IBAL=1;
//IIC0_IBCR=IIC0_IBCR |0xc0;
}

void main(void)
{

DisableInterrupts;

InitIIC();

EnableInterrupts;

for(;;)
{
//Check bus status
while(IIC0_IBSR_IBB);
//Send mode,generate start signal
IIC0_IBCR|=0x30;
//Wait for IBB flag to set
while(!IIC0_IBSR_IBB);

//Transfer the slave address
IIC0_IBDR=0x52;
//Transmission complete
while(!IIC0_IBSR_IBIF);
IIC0_IBSR_IBIF=1;
//Slave ACK occurred
while(IIC0_IBSR_RXAK);

//Transfer data
IIC0_IBDR=50;
//Transmission complete
while(!IIC0_IBSR_IBIF);
IIC0_IBSR_IBIF=1;
//Slave ACK occurred
while(IIC0_IBSR_RXAK);

//generate stop signal
IIC0_IBCR&=0xdf;

}

}

上一篇:美丽的蝴蝶 下一篇:深圳十大女装品牌
图文资讯
广告赞助商