asking
Full Member level 5
- Joined
- Sep 21, 2010
- Messages
- 279
- Helped
- 6
- Reputation
- 12
- Reaction score
- 6
- Trophy points
- 1,298
- Activity points
- 3,377
Please see mikroC PRO PIC example of RTC DS1307. You can get the examples if you install the demo version of mikroC PRO for PIC. You can also get the code from libstock.com Search for RTC DS1307. The code shows how to write data to ds1307, read ds1307.
- - - Updated - - -
Please see mikroC PRO PIC example of RTC DS1307. You can get the examples if you install the demo version of mikroC PRO for PIC. You can also get the code from libstock.com Search for RTC DS1307. The code shows how to write data to ds1307, read ds1307.
24 hr = 100100. In 24 hr mode you dont use 5th bit. 6th bit is used and is 0, so you pass bcd values 0...24. In 12 hr mode you write 5th bit and 6th bit once only. Are you asking how to pass data in this condition?
After doing dec2bcd(12) you get 10010. add 1000000 or 1100000 to it and then write the value to hour.
Just like this ?
hour = BCD2Binary(hour);
hour = hour + set;
hour = Binary2BCD(hour);
hour = hour + 0x40; (0x40 = 0b01000000 6th bit high)
write_ds1307(2, hour);
?