TRIS setting for the DS1302
Hi all
I wonder if someone could please tell me what the TRIS settings should be to work with the DS1302.
I have been checking out code examples through the forums and have even tried a few. I am still not sure of what the TRIS settings should be for my PIC to interact with the DS1302.
So given the following for example :
Code:
RST var PORTA.2
IO var PORTC.1
SCLK var PORTC.3
Kind regards
Dennis
starting to make more sense (I think !)
@ Art
Thanks a million for the reply.
I had already checked out code by Cocacolakid as well as Sayzer and quite a few others, as well as Melanie's example MN1307.txt, with little or no success.
The code from Cocacolakid uses the shiftin/out method not so ?
This is the reason why I asked about the TRIS statement.
Check the first few lines of Cocolakid's code:
Code:
'-------------------------- Clock Variables ---------------------------------
rst var portb.2 ' DS1302 Reset Pin
clk var portb.1 ' DS1302 Clock Pin
dq var portb.0 ' DS1302 Data Pin
What should the TRIS statement be ? Or is this handled by the SHIFTIN/OUT statement ?
Later on in his code there is :
Code:
'------------------------ Initial Settings For Ports ------------------------
low rst ' Set reset pin low
low clk ' Set clock pin low
trisb = 0
trisa = 0
The forum is scattered with many examples for DS1302 and DS1307 and various timers, clocks elapsed timers, olympic clocks and there are even examples for the various LABX boards,even some methods to use a PIC as a timer with accuracy much like that of a DS1302/7 depending on the crystal you choose.
With the wealth of information here it starts becoming rather difficult to figure out which clock chip is a good selection and why.
From what I can see (and I may well be wrong),
if you're using the DS1302 then you should use a shiftin/out method and
if you're using a DS1307 you should use the I2C method.
I am trying to build a very simple alarm clock which triggers on a matching date and time. It will also be used as a datalogger for logging the time and duration of power failures for my generator since we have many power failures in our area at some really odd times.
Your info has been most useful in starting to figure out some parts of this puzzle.
Any more info you or anyone else would also be most welcome.
Kind regards
Dennis
ok :-) definitely gonna try this tonight!
@Steve ..apologies .. was actually asking Malc-c about valentines day :-)
@ Steve , regarding these lines :
Code:
high rst ' Ready for transfer
Shiftout IO, SCLK, LSBFIRST, [$bf] ' Read all 8 RTC registers in burst mode
Shiftin IO, SCLK, LSBPRE, [rtcsec, rtcmin, rtchr, rtcdate, rtcmonth, rtcday, rtcyear, rtccontrol]
low rst ' Reset RTC
I understand these
LSBFIRST ' MODE 0 - Shift data out lowest bit first. Clock idles low.
LSBPRE ' MODE 0 - Shift data in lowest bit first,Read data before sending clock. Clock idles low.
But what is the [$bf] ?
@Malc-c --to err is human :-)
Kind regards
Dennis
ok read funstion understood !
@ Steve ...
Do you have a snippet for the write in burst mode so one can set the clock ?
Kind regards
Dennis