سلام من یک ماژول ds1307 خرید که یک IC 24c32 هم داره من میتونم به 24C32 وصل بشم ولی نمیتونم به DS1307 وصل بشم ادرس DS1307 رو هم می دونم ولی به اون وصل نمیتونم بشم وصل کجاست
لطفا هر که می دونه راهنمایی کنه
کتاب خوانه رو برای DS3231 نوشتم اما منطقا باید روی DS1307 هم کار کنه.
لطفا هر که می دونه راهنمایی کنه
[FONT=Yekan]void DS3231_ReadDateTime(I2C_TypeDef* I2Cx, struct DS3231_DateTime *DS3231_Date)[/FONT]{
while(I2C_GetFlagStatus(I2Cx, I2C_FLAG_BUSY));
I2C_AcknowledgeConfig(I2Cx, ENABLE);// enable acknowledge
I2C_GenerateSTART(I2Cx, ENABLE);
while(!I2C_GetFlagStatus(I2Cx, I2C_FLAG_SB));// wait Generate Start condition
I2C_Send7bitAddress(I2Cx, 0xD0, I2C_Direction_Receiver);
while(!I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED));// wait send address ds3231
while(I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_BYTE_RECEIVED));// wait receive second
DS3231_Date->Seconds = I2C_ReceiveData(I2Cx);
while(I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_BYTE_RECEIVED));// wait receive Minute
DS3231_Date->Minutes = I2C_ReceiveData(I2Cx);
while(I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_BYTE_RECEIVED));// wait receive Hour
DS3231_Date->Hour = 0x1F & I2C_ReceiveData(I2Cx);
while(I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_BYTE_RECEIVED));// wait receive Day(1-7)
DS3231_Date->Day = I2C_ReceiveData(I2Cx);
while(I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_BYTE_RECEIVED));// wait receive Date(1-31)
DS3231_Date->Date = I2C_ReceiveData(I2Cx);
while(I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_BYTE_RECEIVED));// wait receive Month
DS3231_Date->Month = I2C_ReceiveData(I2Cx);
while(I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_BYTE_RECEIVED));// wait receive Year
DS3231_Date->Year = I2C_ReceiveData(I2Cx);
I2C_NACKPositionConfig(I2Cx, I2C_NACKPosition_Current);// create Not acknowledge
I2C_AcknowledgeConfig(I2Cx, DISABLE);// disable acknowledge
I2C_GenerateSTOP(I2Cx, ENABLE);
while(!I2C_GetFlagStatus(I2Cx, I2C_FLAG_STOPF));// wait generate stop condition
I2C_AcknowledgeConfig(I2Cx, ENABLE);// Enable acknowledge
[FONT=Yekan]};[/FONT]
کتاب خوانه رو برای DS3231 نوشتم اما منطقا باید روی DS1307 هم کار کنه.
دیدگاه