在线时间3 小时
UID349690
ST金币0
蝴蝶豆0
注册时间2012-3-27
初级会员
- 最后登录
- 2018-8-1
|
a0a.1 0b0c
I2C连接的设备是TPS65185
I2C_InitTypeDef I2C_InitStructure;
int main(void)
{
SystemInit();
RCC_APB2PeriphClockCmd(RCC_GPIO_USE, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, ENABLE);
PM_PWRUP_H;
PM_WAKEUP_H;
/* Enable I2C1 ----------------------------------------------------*/
I2C_Cmd(I2C1, ENABLE);
/* I2C1 configuration ------------------------------------------------------*/
I2C_InitStructure.I2C_Mode = I2C_Mode_I2C;
I2C_InitStructure.I2C_DutyCycle = I2C_DutyCycle_2;
I2C_InitStructure.I2C_OwnAddress1 = 0x01;
I2C_InitStructure.I2C_Ack = I2C_Ack_Enable;
I2C_InitStructure.I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit;
I2C_InitStructure.I2C_ClockSpeed = 100000;
I2C_Init(I2C1, &I2C_InitStructure);
/*----- First transmission Phase -----*/
/* Send I2C1 START condition */
I2C_GenerateSTART(I2C1, ENABLE);
/* Test on I2C1 EV5 and clear it */
while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_MODE_SELECT));
/* Send I2C1 slave Address for write */
I2C_Send7bitAddress(I2C1, 0x68, I2C_Direction_Transmitter);
/* Test on I2C1 EV6 and clear it */
while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED)); 运行到这里就过不去了, 总是没有回应; 请问哪里出现问题, 谢谢!
/* Send Command */
I2C_SendData(I2C1, 0x01);
while(!I2C_CheckEvent(I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED));
/* Send I2C1 STOP Condition */
I2C_GenerateSTOP(I2C1, ENABLE);
} |
|