Shop OBEX P1 Docs P2 Docs Learn Events
built-in comparator question — Parallax Forums

built-in comparator question

Beau SchwabeBeau Schwabe Posts: 6,568
edited 2005-03-09 04:16 in General Discussion
Just curious if it was possible to configure the internal comparator in an oscillator mode
where B0 was driving OSC1.

No particular application in mind yet, just exploring a possibility for something unique.

I might just try it for kicks.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe - Mask Designer III

National Semiconductor Corporation
(Communication Interface Division)
500 Pinnacle Court, Suite 525
Mail Stop GA1
Norcross,GA 30071

Comments

  • James NewtonJames Newton Posts: 329
    edited 2005-03-08 23:42
    So the SX would be able to stop it's own clock? or... err... what?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ---
    James Newton, Host of SXList.com
    james@sxlist.com 1-619-652-0593 fax:1-208-279-8767
    SX FAQ / Code / Tutorials / Documentation:
    http://www.sxlist.com Pick faster!



  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2005-03-09 00:15
    Obviously you would not want to stop the clock, but I guess you could if you
    really wanted to.

    Years ago, I implemented a method where a processor could kick itself in and
    out of a "turbo mode" (changing it's own clock speed) by setting up an external
    RC oscillator. An I/O pin switched in/out a parallel resistor to accomplish this.

    However I could not switch in/out a crystal very easily, so that the processor
    could wake up from running at a few Hz to 4MHz or so to communicate with
    standard RS232 (RC timing was not accurate enough)

    My thought was to setup the Comparator in a way that I could use a crystal here,
    and program the SX in an RC oscillator mode. An available pin could be made
    to disable the crystal oscillator through the comparator while switching to a "true"
    RC oscillator configuration for extremely low power operational "sleep" mode.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe - Mask Designer III

    National Semiconductor Corporation
    (Communication Interface Division)
    500 Pinnacle Court, Suite 525
    Mail Stop GA1
    Norcross,GA 30071
  • James NewtonJames Newton Posts: 329
    edited 2005-03-09 01:16
    Interesting idea!

    So would the RC circuit always be connected? And the comparitor output would over ride it? So the crystal would be connected to one input of the comparitor and the other would be an RB pin and perhaps a resistor voltage divider. That would get you a nice "half way" voltage when the RB pin was set to an input and then when it was made an output and e.g. set to 0, the crystal would not be able to run... Or no, better yet, just disable the comparitor output so that the connection to OSC1 goes away and only the RC is left...

    It seems like this could be a very good idea to implement outside the SX, I mean to say, not using any SX resources other than an output that selects the speed. For example, a simple crystal osc circuit like this one:
    http://devster.retrodev.com/z80/crystal.gif but using a NAND gate with one input set up as an output enable to start and stop the clock.

    In case you haven't noticed, I have no clue what I'm on about, but this is very interesting so I'm keen to see what will and will not work...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ---
    James Newton, Host of SXList.com
    james@sxlist.com 1-619-652-0593 fax:1-208-279-8767
    SX FAQ / Code / Tutorials / Documentation:
    http://www.sxlist.com Pick faster!



  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2005-03-09 01:34
    I think you are on the right track, but I don't know that I would disable the comparator output....There might be a possibility the oscillator would stall,
    thus no further instructions would be executed.

    A comparator can be configured to act like a schmitt trigger inverter and used in a similar way to the circuit you mention.

    A resistor could be inserted off of a pin and offset the crystal-comparator to a point that it would no longer oscillate from the crystal,
    but at the same time would provide a valid RC oscillator path to the OSC1.

    So on "wakeup" you could insert a precision oscillator to do any real communication i.e to an RTC,Memory,etc. , and then drop down into
    a functional sleep mode at a speed that isn't critical to monitor the status of a few pins etc.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe - Mask Designer III

    National Semiconductor Corporation
    (Communication Interface Division)
    500 Pinnacle Court, Suite 525
    Mail Stop GA1
    Norcross,GA 30071
  • KenMKenM Posts: 657
    edited 2005-03-09 02:10
    For what is it worth, with a higher part count (which is in part probably what you are trying to avoid) Guenthers book describes using a PLL controlled by an output that will change the clock speed on the fly.
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2005-03-09 04:16
    It's not so much a higher component count.... The whole idea of running the SX at a very low speed is to
    minimize the current down to micro amps. Take for example a data logger project, where you want to
    know when an input changes state. In low power mode you could monitor the pins a couple of tens of
    times a second...

    If their state changes, then...
    1) the SX would "power up"
    2) then wake up a RTC (Real time clock)
    3) read the time/date
    4) shutdown the RTC,
    5) wake up an external memory
    6) write the time/date stamp and pin state to the memory
    7) shut down the memory
    8) and finally the SX would go back into low power mode.

    I did this with a previous project using a PIC, and was able to achieve 5 months of operation from a 3V lithium
    battery. The downside was that each unit had to be individually calibrated in turbo mode, so that the information
    from the EEPROM could be dumped into a PC. If I could have inserted a crystal in "turbo" mode, then I could
    have eliminated the calibration requirement for each unit.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe - Mask Designer III

    National Semiconductor Corporation
    (Communication Interface Division)
    500 Pinnacle Court, Suite 525
    Mail Stop GA1
    Norcross,GA 30071
Sign In or Register to comment.