TI中文支持网
TI专业的中文技术问题搜集分享网站

关于F28M36的I2C通信问题

如何用I2C通信向指定存储空间写入指定字节的数据,想要往时钟芯片上写初始的时分秒数据,但是总是写不进去,想要请教一下各位大神。

是否是要使用这个函数?

I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_START);

然后用如下几个量进行组合呢?

#define I2C_MASTER_CMD_BURST_SEND_START 0x00000003
#define I2C_MASTER_CMD_BURST_SEND_CONT 0x00000001
#define I2C_MASTER_CMD_BURST_SEND_FINISH 0x00000005

Xupeng(FAA) He:

我来给你个例子吧,我是向地址为sla的从机中的地址为suba的寄存器写入数据s。

static void ADE7878_SetReg32(short sla,int suba,long s) { I2CMasterSlaveAddrSet(I2C0_MASTER_BASE, sla, false);//false=wright I2CMasterDataPut(I2C0_MASTER_BASE, (suba>>8)&0x00ff); I2CMasterControl(I2C0_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_START); while(I2CMasterBusy(I2C0_MASTER_BASE)){} I2CMasterDataPut(I2C0_MASTER_BASE, suba&0x00ff); I2CMasterControl(I2C0_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_CONT); while(I2CMasterBusy(I2C0_MASTER_BASE)){} I2CMasterDataPut(I2C0_MASTER_BASE, (s>>24)&0x00ff); I2CMasterControl(I2C0_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_CONT); while(I2CMasterBusy(I2C0_MASTER_BASE)){} I2CMasterDataPut(I2C0_MASTER_BASE, (s>>16)&0x00ff); I2CMasterControl(I2C0_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_CONT); while(I2CMasterBusy(I2C0_MASTER_BASE)){} I2CMasterDataPut(I2C0_MASTER_BASE, (s>>8)&0x00ff); I2CMasterControl(I2C0_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_CONT); while(I2CMasterBusy(I2C0_MASTER_BASE)){} I2CMasterDataPut(I2C0_MASTER_BASE, s&0x00ff); I2CMasterControl(I2C0_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH); while(I2CMasterBusy(I2C0_MASTER_BASE)){} // Delay until transmission completes}

这个代码是亲测过的,希望对你有帮助。

赞(0)
未经允许不得转载:TI中文支持网 » 关于F28M36的I2C通信问题
分享到: 更多 (0)