用最简单的轮询方式(用延时代替),代码如下:
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
SysCtlClockSet(SYSCTL_SYSDIV_1|SYSCTL_USE_OSC|SYSCTL_OSC_MAIN|SYSCTL_XTAL_16MHZ);
SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C);
//GPIOPinConfigure(0x00010801);//GPIO_PB2_I2C0SCL
//GPIOPinConfigure(0x00010C03);//GPIO_PB3_I2C0SDA 0x00010C01 //这两行注释和不注释都试过了
GPIOPinTypeI2C(GPIO_PORTB_BASE,GPIO_PIN_2|GPIO_PIN_3);
I2CMasterInitExpClk(I2C_MASTER_BASE,SysCtlClockGet(),false);
I2CMasterSlaveAddrSet(I2C_MASTER_BASE,0xA0,false);
I2CMasterDataPut(I2C_MASTER_BASE,0x00);
I2CMasterControl(I2C_MASTER_BASE,I2C_MASTER_CMD_BURST_SEND_START);
timeDelay(8000); //延时时,很大的数也试过了
I2CMasterDataPut(I2C_MASTER_BASE,0x0a);
I2CMasterControl(I2C_MASTER_BASE,I2C_MASTER_CMD_BURST_SEND_CONT);
timeDelay(8000);
I2CMasterSlaveAddrSet(I2C_MASTER_BASE,0x3B,true);
I2CMasterControl(I2C_MASTER_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH);
timeDelay(8000);
只看到发出I2C_MASTER_CMD_BURST_SEND_START 了,后边发送的那两个数据却看不到.
不知什么原因,谢谢各位了.
此帖出自
小平头技术问答
一周热门 更多>