Shop OBEX P1 Docs P2 Docs Learn Events
Real Time Clock options for the propeller? — Parallax Forums

Real Time Clock options for the propeller?

PointDogPointDog Posts: 22
edited 2006-10-26 12:05 in Propeller 1
Hi all,
I am looking at migrating some of my designs to the propeller, but I am wondering what options there are for a real time clock on the properller? Most others microcontroller have an on-board oscillator and counter that can be used to monitor real time with only the addition of a 32.768khz watch crystal. Also, normally this type of funcion usualy has to continue while the device is in a low power mode, and then the time can then be referenced when the microcontroller resumes full power operation. On other microcontrollers this is done by setting an interrupt to wake the device on clock rollover once every 2-16 seconds to update the ime registers, then return to sleep mode. But the propeller has neither a sleep mode, or a low power clock oscillator. Does anyone have any Ideas?

Thanks in advance.

smile.gif

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-26 01:18
    The Propeller doesn't need a special sleep mode. The system clock is dynamically configurable. Most Propeller boards are furnished with a 5MHz crystal which is multiplied by 16 to make an 80MHz system clock. The multiplier can be changed to 1x, 2x, 4x, or 8x with an appropriate drop in power consumption. There are two other internal clocks that are fairly inaccurate and temperature sensitive. RCFAST may range from 8MHz to 20MHz and RCSLOW can range from 13kHz to 33kHz. The current drain is approximately 500uA * (clock freq in MHz / 4) * # of active cogs. Cogs waiting for a particular system clock time to come (with WAITCNT) or I/O pin status (with WAITPNE or WAITPEQ) are considered inactive along with cogs that are completely stopped (idle). The minimum current is quite low, but you'll have to search for previous comments from Parallax. The easiest thing to do would be to change the clock multiplier to 1x and do a WAITCNT for a time in the future. The system clock counts clock pulses and is a 32 bit register that wraps around. With a 5MHz system clock, you could wait anywhere up to just under 15 minutes in the future at very low power.
  • PointDogPointDog Posts: 22
    edited 2006-10-26 03:25
    That makes sense, and is a better solution than interrupting. Does the propeller need to keep 1 cog running continuously to run the spin interpreter? or could I have 7 idle cogs, and one doing a waitcnt whie the instrument is in the "off" mode? (the unit would not actually be off because the RTC still needs to be maintained, but it would appear to be off to the user.)
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2006-10-26 03:32
    Cog 0 could be keeping time, and be in standby waiting on the count, with no other cogs running.
    -Martin

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Martin Hebel
    StampPlot - Graphical Data Acquisition and Control
    AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers·
  • PointDogPointDog Posts: 22
    edited 2006-10-26 03:50
    Can I do that without using assembly? (ie. with spin) I know that I can write assembly into spin code, but I'd prefer to limit my study of propeller asssembly to the level of understanding the architecture rather than full blown assembly routine writing. Thanks smile.gif
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2006-10-26 04:03
    Yup, it can be as simple as:

    VAR
    Word ss
    
    PUB Time 
       repeat
          waitcnt (clkfreq + cnt)        ' one second wait
          ss:= ss+1                         ' add one to seconds
    
    


    Of course you can adapt seconds to hrs, min, seconds

    Note, due to the time to do waitcnt calculations, the timing will be slightly off, but you can analyze and subtract an amount accordingly, such as:
    waitcnt(clkfreq - 2500 + cnt)

    If you wish to count milliseconds, to help determine the fudge-factor you need:

    waitcnt(clkfreq / 1000 - adjustment + cnt) ' 1 millisecond wait with an adjustment value

    -Martin

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Martin Hebel
    StampPlot - Graphical Data Acquisition and Control
    AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers·
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-26 04:04
    Yeah. SPIN works fine. The interpreter executes a WAITCNT instruction and the cog goes to sleep until the system clock matches the argument to the function call. The cog is "sort of" running, but is paused in a low power state.
  • PointDogPointDog Posts: 22
    edited 2006-10-26 04:07
    Thanks guys, you've been a big help.

    Regards,
    Mark.
  • NewzedNewzed Posts: 2,503
    edited 2006-10-26 12:05
    I needed an RTC, and after looking at the Prop problems involed, I connected the Prop to a BS2 using Pins 0 and 1 for serin/serout.· The BS2 runs my DS1302 and whenever I want the time I send a "G" to the Stamp and it sends back the current time.· Very simple, and saves memory on the Prop.

    Sid

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Sid Weaver
    Don't have VGA?

    Newzed@aol.com
    ·
Sign In or Register to comment.