[SOLVED] DS1307 with ATmega32

Status
Not open for further replies.

remona

Newbie level 4
Joined
Jun 10, 2013
Messages
6
Helped
1
Reputation
2
Reaction score
1
Trophy points
3
Location
Khartoum, Sudan, Sudan
Visit site
Activity points
44
Hello All
i am working on RTC DS1307 interface with ATmega32
i am using built in library of DS1307 in CodeVision AVr.
i cannot set the day of week
can we help me Please :roll:
 

i can not read and set the day of week ,i was used
day=i2c_read(0)& 0x07; to read the content of RTC register "day" and always i have number 7
and used
i2c_start(); //transmit start cpndition
i2c_write(0b11010000); //transmit addres od DS1307 +w
i2c_write(0x03);
i2c_write(day & 0b00000111); //set day of weak
delay_ms(20);
i2c_stop();
i never get that day i was entered
 

what r u means by D3??????????????
In each case i was try that
if i lay day=5 then used

i2c_start(); //transmit start cpndition
i2c_write(0b11010000); //transmit addres od DS1307 +w
i2c_write(0x03); //set register pointer to 03
i2c_write(day); //set day of week "day value"
delay_ms(20);
i2c_stop();

to read day of week used day=i2c_read(3)& 03;
always day =3
 

Try This
i2c_start();
i2c_write(0b11010011);
i2c_write(0b00000111); //set day of weak
delay_ms(20);
i2c_stop();

if it work or not
inform result

- - - Updated - - -

Try This
i2c_start();
i2c_write(0b11010011);
i2c_write(0b00000111); //set day of weak
delay_ms(20);
i2c_stop();

if it work or not
inform result
 
Reactions: remona

    remona

    Points: 2
    Helpful Answer Positive Rating
The objective of the project to give the user the possibility to adjust the day to receive the value of it
So I need to write on the Registrar then read the Registrar to test result
But in the code sender value of each day is always fixed by 3
i2c_write (0b00000111); / / set day of weak
 
From above I guess like this
1. User always set Day as per his choice. so u required day setting. I suggest first check whether logic work for any day value which may 1 to 7 . for this u set fix value check if it work then u change ur logic.
2. In code sender u say always fixed value =3 but in write command u write 0x00000111 which = 0x07 so which is correct
 
Reactions: remona

    remona

    Points: 2
    Helpful Answer Positive Rating
Thank you a lot for you try to help me, finally ,I was resolved the problem and got the desired results, interest permeated i was used :
/* set Day of weak from DS1307 */
i2c_start(); //transmit start cpndition
i2c_write(0xD0); //transmit addres od DS1307 +w
i2c_write(0x03); //set Dregister pointer to 03
i2c_write(day); //set day of weak
delay_ms(20);
i2c_stop();
/* Read current "Day" from DS1307 */
i2c_start();
i2c_write(0xD0); // transmit addres od DS1307 +w
i2c_write(0x03); // set register pointer to 3
i2c_start();
i2c_write(0xD1); // RD from RTC
day = i2c_read(0)& 07; // Read current "Day" in DS1307
i2c_stop();

Thanks alot :smile:
 

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…