使用ch32v203,一直卡在"I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED",这步骤,会是什么原因造成呢,使用的历程是使用iic写AT24C08,
void AT24CXX_WriteOneByte(u16 WriteAddr, u8 DataToWrite) { while( I2C_GetFlagStatus( I2C1, I2C_FLAG_BUSY ) != RESET ); I2C_GenerateSTART( I2C1, ENABLE ); printf("111111111\r\n"); while( !I2C_CheckEvent( I2C1, I2C_EVENT_MASTER_MODE_SELECT ) ); I2C_Send7bitAddress( I2C1, 0XA0, I2C_Direction_Transmitter ); printf("22222222\r\n"); while( !I2C_CheckEvent( I2C1, I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED ) ); printf("3333333\r\n"); #if (Address_Lenth == Address_8bit) I2C_SendData( I2C1, (u8)(WriteAddr&0x00FF) ); while( !I2C_CheckEvent( I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED ) ); printf("444444\r\n"); #elif (Address_Lenth == Address_16bit) I2C_SendData( I2C1, (u8)(WriteAddr>>8) ); while( !I2C_CheckEvent( I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED ) ); I2C_SendData( I2C1, (u8)(WriteAddr&0x00FF) ); while( !I2C_CheckEvent( I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED ) ); #endif if( I2C_GetFlagStatus( I2C1, I2C_FLAG_TXE ) != RESET ) { I2C_SendData( I2C1, DataToWrite ); } printf("555555\r\n"); while( !I2C_CheckEvent( I2C1, I2C_EVENT_MASTER_BYTE_TRANSMITTED ) ); I2C_GenerateSTOP( I2C1, ENABLE ); }
热门产品 :
CH182: 以太网PHY收发器芯片