ds1307 in assembly - Page 1
Forum section: electronics / general

author: Toruk.makto
author_rank: Newbie
timestamp: February 12, 2014, 11:39:11 am
content: 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 offthe 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 simpleprogram 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/twdrthe program:http://www.mediafire.com/view/q2jvdprp4u3micz/ds1307+.asmschematic:http://img4u.ir/upload/427ds1307+.JPG

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: February 12, 2014, 12:09:21 pm
content: does the 1307 have Vcc and ground?

author: dannyf
author_rank: Super Contributor
timestamp: February 12, 2014, 12:10:10 pm
content: QuoteMy advice to you: learn to program in C, if you are a beginner. Assembly is useful if you are dedicated to doing simple things or you are very experienced and have lots of time / money.

author: Toruk.makto
author_rank: Newbie
timestamp: February 12, 2014, 03:13:32 pm
content: Quote from: HackedFridgeMagnet on February 12, 2014, 12:09:21 pmof course had

author: Lajon
author_rank: Contributor
timestamp: February 12, 2014, 04:54:13 pm
content: Comparing your;-------------------reading second from ds1307 and send to portacall delaymain: call i2c_initcall i2c_startldi r16,208call i2c_sendcall i2c_startldi r16,209call i2c_sendldi r16,0x00call i2c_sendin r18,twdrout porta,r18call i2c_stopcall delay_1secrjmp mainwith Arduino lib I googled it appears that you are not doing the reading correctly. The 0 (which is for selecting register 0 in the DS1307) should be part of the write sequence.WIRE.beginTransmission(DS1307_ADDRESS);WIRE.write(0);WIRE.endTransmission();WIRE.requestFrom(DS1307_ADDRESS, 7);uint8_t ss = bcd2bin(WIRE.read() & 0x7F);/Lars

author: Toruk.makto
author_rank: Newbie
timestamp: February 13, 2014, 01:39:55 pm
content: Quote from: Lajon on February 12, 2014, 04:54:13 pmiwrite the code like this:call delaymain: call i2c_initcall i2c_startldi r16,208call i2c_sendldi r16,0x00call i2c_sendcall i2c_startldi r16,209call i2c_sendin r18,twdrout porta,r18call i2c_stopcall delay_1secrjmp mainand then 0xD1 (or 209) appears on port A and its not changed never.

author: Toruk.makto
author_rank: Newbie
timestamp: February 14, 2014, 09:43:24 am
content: i find the problem code must be write like this:call delaymain: call i2c_initcall i2c_startldi r16,208call i2c_sendldi r16,0call i2c_sendcall i2c_startldi r16,209call i2c_sendldi r16,0x00call i2c_sendin r18,twdrout porta,r18call i2c_stopcall delay_1secrjmp main

author: uwezi
author_rank: Unknown
timestamp: February 18, 2014, 10:43:48 pm
content: I spend hours and hours on a batch of DS1307 which I had bought on eBay from China for a student lab.Some worked for a short time, then became hot - almost letting the gray smoke come out which drives then. Other did never work at all.Running the same, exact same code on legitimate DS1307 from a commercial reseller in Sweden worked flawlessly!It really took me a while to realize that I must have gotten counterfeit chips.I was pulling all strings on possible circuit and software errors, tried my own I2C code and two or three external libraries. Replaced the crystals a dozen times, checked the battery connection, changed the battery, replaced the battery with a diode-circuit to fake the battery voltage...