Hi jay_3189,
Bit4 to bit6 represents the tens place of the value and bit0 to bit 3 represents the ones place of the value. For example, to set a value of 34, write 0x03 to bits4 to 6 and write 0x04 to bits0 to 3.
Regards,
Raj Gunaseelan
- - - Updated - - -
In register 0x02, bit6 is used to select the hour format: 1 to 12 am/pm (or) 0 to 23 hour format. If 1 to 12 am/pm format is selected, bit 5 gives am or pm, bit4 gives the tens value of hour, bits3 to 0 give the ones value of hour. If 0 to 23 hour format is selected, bits5 to 4 give the tens value of hour, bit3 to 0 give ones value of hour.
Regards,
Raj Gunaseelan
as datasheet saying resistors have BCD value
does I write values in hexadecimal only or in other format?
Yes, BCD format is what I explained.
No. hexadecimal is different from BCD. For example, a decimal value of 65 is represented in hexadecimal as 0x41, whereas for the RTC register you need to split 65 as 0x06(tens place) and 0x05(ones place). BCD is nothing but Binary Coded Decimal.
For reading, assume setting is for 24hour format, if register 0x02 reads a value 00100011, (00)10 gives 2(tens) and 0011 gives 3(ones). Therefore, the hour is 23.
Regards,
Raj Gunaseelan
and how could I read value?
I mean if I call resistor address then it won't get date , year or anything directly in in decimal?
decimal = (((153 & 0xF0) >> 4) * 10) + (153 & 0x0F )
No you cannot read direct decimal. suppose you set the year as 99. You do this by writing 0x09(tens) and 0x09(ones). While reading the same register, you get 153 decimal which is 99 in BCD. So, you have to decode 153 as 99 through code as shown below:
Code:decimal = (((153 & 0xF0) >> 4) * 10) + (153 & 0x0F )
Regards,
Raj Gunaseelan
Year 1989
You can set only 00 to 99
19 set in manually in the source code
void write_ds1307(unsigned short address,unsigned short w_data)
{
i2c_Start(); // issue I2C start signal
i2c_Write(0xD0); // send byte via I2C (device address + W)
i2c_Write(address); // send byte (address of DS1307 location)
i2c_Write(w_data); // send data (data to be written)
i2c_Stop(); // issue I2C stop signal
}
ya It's done but one problem is there still
The second stamp is running quickly in comparison to REAL TIME SCENARIO
There is no "19", the year settings refer to 2000 - 2099 and the programmed leap years are for 2000-2099, not 1900-1999
Check The two capacitors that connected to the clock Crystal or change the another crystal 32768KHz
Actually what happen if we set it to increment from 1900 to 1999
FEATURES:
ƒ Real-Time Clock (RTC) Counts Seconds, Minutes, Hours, Date of the Month, Month, Day of the week, and Year with Leap-Year Compensation Valid Up to 2100
There are no capacitors (and if there are it is wrong), the device needs just a crystal connected between X1-X2 pins but as close as possible
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?