本帖最后由 thinpadhoho 于 2010-5-13 16:11 编辑
我用STM32读外部RTC(8025),IIC通讯,主机发0x64后,然后开始读,通过示波器我发的数据是对的,0x64+读标志位=发的应该是0x65,但没有收到应答位,速度100K,第一次执行I2C_Send7bitAddress,发的是0x65,是8位,没有收到应答位,再单步执行I2C_Send7bitAddress的话,发的就是0x65 0x65 变成16位了,这是怎么回事?
程序如下:
/* I2C1 configuration ------------------------------------------------------*/
I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
I2C_InitStructure.I2C_OwnAddress1 = I2C1_SLAVE_ADDRESS7;
I2C_InitStructure.I2C_Ack = I2C_Ack_Enable ;
I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
I2C_InitStructure.I2C_ClockSpeed = ClockSpeed;
I2C_Init(I2C1, &I2C_InitStructure);
I2C_GenerateSTART(I2C1, ENABLE);
while(1)
{
I2C_Send7bitAddress(I2C1, 0x64, I2C_Direction_Receiver);
}
for(i=0; i<16; i++)
{
//if((I2C_CheckEvent(I2C1,
I2C_EVENT_MASTER_BYTE_RECEIVED)))
Buffer = I2C_ReceiveData(I2C1);
} |