PDA

View Full Version : string() function not accepting DS1302 variables



Francisco
11-18-2010, 08:56 PM
Hello all,

I am trying to set the time in the BackPack using a DS1302 time chip with the following code:



rtc.readTime( @hour, @minute, @second ) 'read time from DS1302
rtc.readDate( @day, @month, @year, @dow ) 'read date from DS1302
pr.str(string(SETTIM, year, month, day, hour, minute, second)) 'set time on backpack


the object im using for the ds1302 is from here: http://obex.parallax.com/objects/519/

The compile error i get is: Error: Not a Long Address

basically the string() is not accepting the date variables.

To debug, I tried creating new variables of type LONG and then reassigned the date values to these new longs to see if it would work but still not working.

Does anyone have a clue?

Thank you.

Mike Green
11-18-2010, 10:16 PM
STRING() only works on constants and constant expressions, not variables. You'll have to do something like:

pr.out(SETTIM)
pr.out(year)
pr.out(month)
pr.out(day)
pr.out(hour)
pr.out(minute)
pr.out(second)

I don't know what kind of device is handled by pr.
If it's a serial port (like FullDuplexSerial) you'll need to use .tx instead of .out

Francisco
11-19-2010, 04:15 AM
STRING() only works on constants and constant expressions, not variables. You'll have to do something like:

pr.out(SETTIM)
pr.out(year)
pr.out(month)
pr.out(day)
pr.out(hour)
pr.out(minute)
pr.out(second)

I don't know what kind of device is handled by pr.
If it's a serial port (like FullDuplexSerial) you'll need to use .tx instead of .out

Green, your example worked perfectly! You are one of those members here that I can count on helping out. Thanks again.