Shop OBEX P1 Docs P2 Docs Learn Events
string() function not accepting DS1302 variables — Parallax Forums

string() function not accepting DS1302 variables

FranciscoFrancisco Posts: 26
edited 2010-11-18 21:15 in Propeller 1
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.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-11-18 15:16
    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
  • FranciscoFrancisco Posts: 26
    edited 2010-11-18 21:15
    Mike Green wrote: »
    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.
Sign In or Register to comment.