具体表象为 iic start 、发送从设备地址后,等待 I2C_ENDAD 死循环。 /* Generate the START condition */ I2C_STARTGenerate (I2C, ENABLE); /* Wait until SB bit is set */ while (I2C_FlagStatus (I2C, DIRECT, I2C_SB )== RESET); /* Send the EEPROM address with LSB bit reset */ I2C_AddressSend (I2C,DeviceADDRESS,I2C_Mode7, I2C_TX); /* Wait until ENDAD bit is set */ while (I2C_FlagStatus (I2C, DIRECT, I2C_ENDAD )== RESET); --》死机
谢谢 关于I2C_ENDAD的设置,在芯片资料的180页有这样的解释: ENDAD: End of address transmission. This bit is set by hardware when: - 7-bit addressing mode: the address byte has been transmitted; - 10-bit addressing mode: the MSB and the LSB have been transmitted during the addressing phase. When the master needs to receive data from the slave, it has to send just the MSB of the slave address once again; hence the ENDAD flag is set, without waiting for the LSB of the address.It is cleared by software by reading SR2 and a following write to the CR or by hardware when the interface is disabled (PE=0). 0: No end of address transmission 1: End of address transmission
/******************************************************************************* * Function Name : I2C_FlagStatus * Description : Checks whether any I2C Flag is set or not. * Input : I2Cx ( I2C0 or I2C1 ) * Access(DIRECT or INDIRECT) * Flag : the flag to be read * input 4: an (u8) variable needed in the case * of the INDIRECT access * Return : the NewState of the Flag (SET or RESET). *******************************************************************************/ FlagStatus I2C_FlagStatus (I2C_TypeDef *I2Cx, RegisterAccess Access, I2C_Flags Flag, ...) { [0xe92d000f] stmfd r13!,{r0-r3} [0xe92d4008] stmfd r13!,{r3,r14} u32 Tmp=0;
if (Access == DIRECT) [0xe1a02001] mov r2,r1 [0xe3520001] cmp r2,#1 [0xe59d1010] ldr r1,[r13,#0x10] [0x1a000007] bne 0x400087ec ; (I2C_FlagStatus + 0x38) /* Store in Tmp variable the register where is located the flag */ Tmp = I2C_GetStatus(I2Cx)&Flag; [0xe0000001] and r0,r0,r1 [0xea000006] b 0x40008808 ; (I2C_FlagStatus + 0x54) else { /* Get the fourth register */ va_list list;