Quantcast
Channel: MCS Electronics Forum
Viewing all articles
Browse latest Browse all 20606

BASCOM-AVR : DS1307 RTC : REPLY

$
0
0
Mark- Thanks for the reply and I did see that post with the Xmega I2C/TWI scanner. So far a few things found. Doing this incrementally. 1. The Xtal on the DS1307 chip was bad. Verified with scope. 2. Ran the code in the samples directory, I2cscan.bas. Modify for my target uC, only. Doesn't work, no devices found. I then looked at the Xmega code from above. You have two functions that are not in the sample code. Config TWI and I2Cinit. Add these two calls into the code and the device is found. [code:1:f0936ed374] $regfile = "m128def.dat" $hwstack = 80 $swstack = 80 $framesize = 160 $crystal = 14745600 ' External Xtal, full swing mode $baud = 115200 ' set baud rate Config Sda = Portd.1 ' define pin names, scl and sda pins Config Scl = Portd.0 $lib "i2c_twi.lbx" ' using hardware I2C, scl=D.0, sda=D.1 Config Twi = 100000 ' not is sample dir, in Xmega code example, must have to function properly i2cinit ' not is sample dir, in Xmega code example, must have to function properly Dim B As Byte Print "Start Scan" For B = 0 To 254 step 2 Print b; " "; I2cstart 'Print "I2Cwrite" I2cwbyte B If Err = 0 Then print:Print "Slave at : " ; B ; " hex : " ; Hex(b) ; " bin : " ; Bin(b) End If I2cstop Next Print "End Scan" do:loop [/code:1:f0936ed374] If the calls are valid maybe the sample dir example can have the changes add along with the addition of the Xmega code example in the I2C directory. I am now going to turn on the SQWout pin of the DS1307 and start to verify the RTC routine / timer. I would like to place the AVR's TOSC1/2 pins to be driven by an external clock from the DS1307. That way I don't need two 32.768KHZ xtals. Change the control reg of the DS1307 and the ASSR of the m128. Just want to understand the following first though. Question : Does the DS1307 get accessed every second when the CONFIG CLOCK = USER? From the help file an ISR is created, not sharable. Or does it only access the RTC when a date/time is set/get? If that is the case then why the timer ISR? I read that the library ds1307clock.lib doesn't have to be included in another forum thread. Is that true for correct operation? There appears to be other code in the .lib that is not in the setdate/time getdatetime routines. Thanks! Moving in the correct direction again.

Viewing all articles
Browse latest Browse all 20606

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>