This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C129ENCPDT IIC通信只能发送从机地址

Other Parts Discussed in Thread: TM4C123GH6PM, TM4C129ENCPDT

之前用过TM4C123GH6PM作IIC通信,主机和从机正常通信。最近有一个项目,我选择了TM4C129ENCPDT这款芯片。同样作IIC通信时,发现主机只能发出从机地址,而不能再继续发送数据。程序如下部分代码如下:

uint32_t tx[3] = {0};
int main(void)
{
g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_12MHZ |SYSCTL_OSC_INT |SYSCTL_USE_PLL |SYSCTL_CFG_VCO_480), 12000000);
I2C0_master_init();
tx[0] = 0x1;
tx[1] = 0x2;
tx[2] = 0x3;

while(1)
{
IIC_WriteData(0x3C,0x80,tx,3);
ROM_SysCtlDelay(g_ui32SysClock/3000);
}
}
void I2C0_master_init(void)
{
SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
GPIOPinConfigure(GPIO_PB2_I2C0SCL);
GPIOPinConfigure(GPIO_PB3_I2C0SDA);
GPIOPinTypeI2CSCL(GPIO_PORTB_BASE,GPIO_PIN_2);
GPIOPinTypeI2C(GPIO_PORTB_BASE,GPIO_PIN_3);
I2CMasterInitExpClk(I2C0_BASE, g_ui32SysClock, false);
I2CMasterEnable(I2C0_BASE);
}
void IIC_WriteData(uint32_t slave_add,uint32_t address,uint32_t *data,uint32_t num)
{
uint32_t i=0;
I2CMasterSlaveAddrSet(I2C0_BASE,slave_add,false);

while(I2CMasterBusBusy(I2C0_BASE));
I2CMasterDataPut(I2C0_BASE,address);
I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START);

for(i=0;i<num-1;i++)
{
while(I2CMasterBusy(I2C0_BASE));
I2CMasterDataPut(I2C0_BASE,data[i]);
I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT);
}

while(I2CMasterBusy(I2C0_BASE));
I2CMasterDataPut(I2C0_BASE,data[num-1]);
I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH);

while(I2CMasterBusy(I2C0_BASE));
I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_STOP);

}

示波器获取的波形如下:


在网上看了很多资料,都在说硬件IIC有干扰,不稳定。是这样吗?但是我用TM4C123GH6PM时,主从机都能通信。