[SOLVED] Does anyone know on updating bit 6 on address 02 on DS1307 ?

Status
Not open for further replies.

bianchi77

Advanced Member level 4
Joined
Jun 11, 2009
Messages
1,313
Helped
21
Reputation
44
Reaction score
20
Trophy points
1,318
Location
California
Visit site
Activity points
9,442
Guys,

Does anyone know on updating bit 6 on address 02 on DS1307 ?
Is it directly write like this ?
i2c_write(ds1307_addr[2]);//hour

I'm confused on changing bit 6

can it be only ds1307_addr[2]=0x40 ?

Any concerns will be appreciated,
thank you
 

can I do it in hard code ? I want to write 22:00
looks like it's not working when I did :


ds1307_addr[2]++;
if (ds1307_addr[2] >= 24)
{
ds1307_addr[2] = 0;

}

ds1307_addr[2] = 0x22;
Write_DS1307();//hour
 


Code C - [expand]
1
0x22

has to be written to hours register to set it to 22:00 hours. You are writing it to some array. You have to write it to the register of DS1307 using I2C. The registers are accessed in sequence, so, you can't write just to hours register. You have to write to all the registers in sequence.
 

I got it :
Code:
ds1307_addr[2] = 0x22;
	i2c_write(ds1307_addr[2]);//hour

Thanks for helping
 

I you just need to update the 6th bit without changing the remaining data, then you will first need to get the data that is stored in the register.
Then do bitwise OR with it and then write the data back into the memory.
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…