DS1302 Problem
Archiver
Posts: 46,084
In a message dated 7/20/2004 2:25:35 PM Eastern Daylight Time,
jwilliams@p... writes:
> If the DS1302 does indeed return 1 to 7 for the day, just subract 1 for
> the LOOKUP:
>
Jon, here is what I hve and it works great:
Day1 DATA "Sun"
Day2 DATA "Mon"
Day3 DATA "Tue"
Day4 DATA "Wed"
Day5 DATA "Thu"
Day6 DATA "Fri"
Day7 DATA "Sat"
FOR idx = 0 TO 2 ' get day name
READ (Day1+((day-1)*3)+idx), dyStr(idx)
NEXT
FOR idx = 0 TO 2
DEBUG dystr(idx)
NEXT
DEBUG cr
Sid
[noparse][[/noparse]Non-text portions of this message have been removed]
jwilliams@p... writes:
> If the DS1302 does indeed return 1 to 7 for the day, just subract 1 for
> the LOOKUP:
>
Jon, here is what I hve and it works great:
Day1 DATA "Sun"
Day2 DATA "Mon"
Day3 DATA "Tue"
Day4 DATA "Wed"
Day5 DATA "Thu"
Day6 DATA "Fri"
Day7 DATA "Sat"
FOR idx = 0 TO 2 ' get day name
READ (Day1+((day-1)*3)+idx), dyStr(idx)
NEXT
FOR idx = 0 TO 2
DEBUG dystr(idx)
NEXT
DEBUG cr
Sid
[noparse][[/noparse]Non-text portions of this message have been removed]
Comments
having an small issue with the
DS1302 on the BS2P40. I have a test module which consists of a
BS2P40 Demo Board connected to a 20 X 4 LCD and my laptop.
I have sample code from various sources for testing LCD chips &
displays, keypads, sound chips, etc. Recently I was playing around
with Jon Williams code for the DS1302 from the Stampworks manual.
That sample code does not include handling the Date, Month or Year,
so I tried to add it. However, when my code tries to do a rollover
for the Day, Date & Month, I noticed my Day variable ends up as $07
instead of $00, which means it's not rolling over back to Sunday.
I know when you've been working on code for a long time it's easy to
overlook something simple, so I am asking if someone fluent with the
DS1302 could take a look at my code and see if I am reading/writing
the data to/from the DS1302 correctly?
Remember, this is a test module. The code uses DEBUG for now, and
should be ported to the LCD Display once I've figured out what my
mistake is (Or someone else does).
Instead of pasting a HUGE amount of code here, I will link to the
code on one of my web sites.
http://www.lightlink.com/dream/bs2pcode.bsp
I appreciate any help on this. Thanks!
Chris Savage
Knight Designs
docs (when all else fails...) and it shows the day value to be from 1 to
7. Can you make it roll over from 7 to 1?
-- Jon Williams
-- Applications Engineer, Parallax
-- Dallas Office
Original Message
From: Chris Savage [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=5xuHCFDWx-6xHeCuMGebnydSaEMLV83rnctAmVd5pmJY8gHLfsGDsFU6NAF40b9bzKZlNHKjvZrcODcqZO1aDW8]knight_designs@y...[/url
Sent: Tuesday, July 20, 2004 11:12 AM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] DS1302 Problem
I decided to repost this under it's own subject line. I myself am
having an small issue with the
DS1302 on the BS2P40. I have a test module which consists of a BS2P40
Demo Board connected to a 20 X 4 LCD and my laptop.
I have sample code from various sources for testing LCD chips &
displays, keypads, sound chips, etc. Recently I was playing around with
Jon Williams code for the DS1302 from the Stampworks manual. That sample
code does not include handling the Date, Month or Year, so I tried to
add it. However, when my code tries to do a rollover for the Day, Date &
Month, I noticed my Day variable ends up as $07 instead of $00, which
means it's not rolling over back to Sunday.
I know when you've been working on code for a long time it's easy to
overlook something simple, so I am asking if someone fluent with the
DS1302 could take a look at my code and see if I am reading/writing the
data to/from the DS1302 correctly?
Remember, this is a test module. The code uses DEBUG for now, and should
be ported to the LCD Display once I've figured out what my mistake is
(Or someone else does).
Instead of pasting a HUGE amount of code here, I will link to the code
on one of my web sites.
http://www.lightlink.com/dream/bs2pcode.bsp
I appreciate any help on this. Thanks!
Chris Savage
Knight Designs
wrote:
> I haven't had a chance to connect a DS1302 yet, but I did just
check the
> docs (when all else fails...) and it shows the day value to be
from 1 to
> 7. Can you make it roll over from 7 to 1?
I can try it...But when I do I will need a dummy value to fill the
LOOKUP table for the days (Text), since (Unless I am wrong), lookup
returns a value starting with 0 for the first item in the index.
Since I am using your code from the Stampworks experiment, I was
using the same index range you were, which is 0-6. If it's 7 then
that means the original code won't work properly without changing
the index range. I hope I made sense...I know what I want to say,
but what do you think, Jon?
Chris Savage
Knight Designs
wrote:
> I haven't had a chance to connect a DS1302 yet, but I did just
check the
> docs (when all else fails...) and it shows the day value to be
from 1 to
> 7. Can you make it roll over from 7 to 1?
> -- Jon Williams
> -- Applications Engineer, Parallax
> -- Dallas Office
Okay, I put a NULL value into the LOOKUP, and now it does roll from
7 to 1, however, if you don't set the day register, it contains a 0,
which I thought was kinda weird. I guess I expected that it
couldn't hold a zero if it's normal range is 1-7. So do you think
that's it then?
Chris Savage
Knight Designs
and get it (StampWorks code -- updated) going for you -- if we ever
meet, you can by me a beverage (I like Guiness). Deal?
If the DS1302 does indeed return 1 to 7 for the day, just subract 1 for
the LOOKUP:
LOOKUP (day - 1), [noparse][[/noparse]Sun, Mon, Tue, Wed, Thu, Fri, Sat], work
-- Jon Williams
-- Applications Engineer, Parallax
-- Dallas Office
Original Message
From: Chris Savage [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=rjWq8xlS3wO0e_WidARqWw34OZcO0xJx_SuoII395G2o_RvfzgY5hhZLKBcF49sGibpRS3fnsFmGN9MDbAY]knight_designs@y...[/url
Sent: Tuesday, July 20, 2004 12:32 PM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] Re: DS1302 Problem
--- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
wrote:
> I haven't had a chance to connect a DS1302 yet, but I did just
check the
> docs (when all else fails...) and it shows the day value to be
from 1 to
> 7. Can you make it roll over from 7 to 1?
I can try it...But when I do I will need a dummy value to fill the
LOOKUP table for the days (Text), since (Unless I am wrong), lookup
returns a value starting with 0 for the first item in the index.
Since I am using your code from the Stampworks experiment, I was
using the same index range you were, which is 0-6. If it's 7 then
that means the original code won't work properly without changing
the index range. I hope I made sense...I know what I want to say,
but what do you think, Jon?
Chris Savage
Knight Designs
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject
and Body of the message will be ignored.
Yahoo! Groups Links
This message has been scanned by WebShield. Please report SPAM to
abuse@p....
wrote:
> When I get back from my class this afternoon I'll hook-up the
circuit
> and get it (StampWorks code -- updated) going for you -- if we ever
> meet, you can by me a beverage (I like Guiness). Deal?
>
> If the DS1302 does indeed return 1 to 7 for the day, just subract
1 for
> the LOOKUP:
>
> LOOKUP (day - 1), [noparse][[/noparse]Sun, Mon, Tue, Wed, Thu, Fri, Sat], work
> -- Jon Williams
> -- Applications Engineer, Parallax
> -- Dallas Office
Okay, I changed the code again to remove the Nul, and replace the
LOOKUP line with your suggestion. Now the code does work. I guess
given this new information, all I really need is confirmation that
my register reads/writes are being correctly addressed. If this is
the case, I am set. However, I will still owe you a guiness! I
myself prefer Molsen Ice, although I haven't had a beer in about 4
years.
Chris Savage
Knight Designs
> Jon, here is what I hve and it works great:
> Day1 DATA "Sun"
> Day2 DATA "Mon"
> Day3 DATA "Tue"
> Day4 DATA "Wed"
> Day5 DATA "Thu"
> Day6 DATA "Fri"
> Day7 DATA "Sat"
> FOR idx = 0 TO 2 ' get day name
> READ (Day1+((day-1)*3)+idx), dyStr(idx)
> NEXT
> FOR idx = 0 TO 2
> DEBUG dystr(idx)
> NEXT
> DEBUG cr
> Sid
Sid, while the code you have here works fine with you, I was working
with code already written and published by Jon & Parallax, and was
originally thinking my changes to the code were the problem,
however, it appears that the original lookup value needed to be
changed, and has been. I see you are using 3-Letter abbreviations,
but for this project I am using full labels, including for the
months. But thanks for putting up your code and showing us your way
for doing this.
Chris Savage
Knight Designs
day register. Since you have the hardware setup already, you could
easily check. That said, it may be safe to initialize hardware to known
states (from your program's point-of-view) and not count on what the
hardware may or may not do.
-- Jon Williams
-- Applications Engineer, Parallax
-- Dallas Office
Original Message
From: Chris Savage [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=GqKVidQ49EM37M3eMeVkNcRumw-zvYCaRONBhUoqX_myJv2-NQoV1xY4jlZ9fD_dfCmvnkKMDlk1XpU4ROqDQ993]knight_designs@y...[/url
Sent: Tuesday, July 20, 2004 12:51 PM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] Re: DS1302 Problem
--- In basicstamps@yahoogroups.com, "Jon Williams" <jwilliams@p...>
wrote:
> I haven't had a chance to connect a DS1302 yet, but I did just
check the
> docs (when all else fails...) and it shows the day value to be
from 1 to
> 7. Can you make it roll over from 7 to 1?
> -- Jon Williams
> -- Applications Engineer, Parallax
> -- Dallas Office
Okay, I put a NULL value into the LOOKUP, and now it does roll from
7 to 1, however, if you don't set the day register, it contains a 0,
which I thought was kinda weird. I guess I expected that it
couldn't hold a zero if it's normal range is 1-7. So do you think
that's it then?
Chris Savage
Knight Designs
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject
and Body of the message will be ignored.
Yahoo! Groups Links
This message has been scanned by WebShield. Please report SPAM to
abuse@p....