SparkFun Forums 

Where electronics enthusiasts find answers.

Discussions on the software and hardware for Atmel's STK standard.
By Toruk.makto
#168378
i want drive a ds1307 with ATmega32 in assembly

(ATmega32 works in 8 MHZ internal oscillator mode)

i use this simple program for drive ds1307 and its not working ...

leds randomly turn on and off

the purpose of this program is first send primary Values to ds1307

(second/minute/hour/day/month/year)

and then reading second and send it to porta.(to show on leds)

would you please correct this program or write another simple

program like this one

(i am beginner in assembly and i searched internet and found nothing )

attention: this mode i used in my program called hardware i2c mode which is used pc0 and pc1 as scl and sda

and use registers like twbr/ /twsr/twcr/twdr

the program:
http://www.mediafire.com/view/q2jvdprp4 ... s1307+.asm

schematic:
http://img4u.ir/upload/427ds1307+.JPG
By jremington
#168386
It is really easy to interface the ds1307 in C or C++, and there are plenty of examples, so why do you want to use assembly?

If the purpose is just to learn machine language programming, do something simpler to start with. It is extremely unlikely that someone will be willing to read through your assembly program and correct it.
By stevech
#168401
i want drive a ds1307 with ATmega32 in assembly
But why assembly language? Seems so imprudent.
By Valen
#168423
Using a logic analyser would also help in debugging this. There could be timing issues involved. Or you could atleast check what the I2C device returns based on what you feed it. And in what pattern the leds light up.

At the very least I suggest you add code routines to send the I2C state and received data to the UART port as debug information.