[bascom] DS1302 bascom AVR example anywhere?
Been fighting with the dallas 3 wire interface for the last two days and I
just can't get it working. I had it working dandy on the stamp before
(thanks to example code).
The only bascom example I can find uses assembly, which I don't understand.
Google and yahoo don't turn up anything. There was an old post here in the
group asking the same thing, but no answers...
The DS1302 is the only chip I could find. I really wanted the PCF8583 and
the nice simple I2C but, none in town.
Short of that, would anyone happen to know the bascom equivilent of the
following two pbasic snippets? On shiftout I'm thinking LSBFIRST would be
the same as option 3. On Shiftin, I thinking option 2 is the same as LSBPRE.
'Write to DS1302
HIGH RTCCS
SHIFTOUT Dta, Clk, LSBFIRST, [%0\1,RTCCmd\5,%10\2,Value]
LOW RTCCS
ReadRTCBurst:
'Read all time-keeping registers in one burst
HIGH RTCCS
SHIFTOUT DTA, Clk, LSBFIRST, [%1\1,BrstReg\5,%10\2]
SHIFTIN DTA, Clk, LSBPRE, [Seconds,Minutes,Hours,Date,Month,Day,Year]
LOW RTCCS
RETURN
What I've tried for the burst read is this:
RTC_CLK alias portd.2
RTC_READ alias pind.3
RTC_WRITE alias portd.3
RTC_SELECT alias portd.4
read_rtc_date_burst:
seconds=0
minutes=0
hours=0
RTC_CMD=&B11111110
Config RTC_READ=output
shiftout RTC_WRITE,RTC_CLK,RTC_CMD,3
Config RTC_READ=INPUT ' worried about this making me miss a pulse
SHIFTIN RTC_READ,RTC_CLK,seconds,2
SHIFTIN RTC_READ,RTC_CLK,minutes,2
SHIFTIN RTC_READ,RTC_CLK,hours,2
SHIFTIN RTC_READ,RTC_CLK,daynum,2
SHIFTIN RTC_READ,RTC_CLK,month,2
SHIFTIN RTC_READ,RTC_CLK,dayweek,2
SHIFTIN RTC_READ,RTC_CLK,year,2
return
All I get on reads is 255 (FF in BCD). I believe I should be getting zeros
until I manage to write a date. Kind of hard knowing whats happening..
My 'lectronic Newb site http://members.shaw.ca/pmeloy/